From 4f0ffa1d30a8406ab71a4612a723455df708e953 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 18 Jun 2018 14:28:17 -0700 Subject: [PATCH] don't rewrite if already converted (#875) --- editor/extension.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/editor/extension.ts b/editor/extension.ts index 07f119df..b436056e 100644 --- a/editor/extension.ts +++ b/editor/extension.ts @@ -433,7 +433,11 @@ namespace pxt.editor { const nodes = U.toArray(dom.querySelectorAll("block[type=device_show_leds]")) .concat(U.toArray(dom.querySelectorAll("block[type=device_build_image]"))) .concat(U.toArray(dom.querySelectorAll("block[type=device_build_big_image]"))) - nodes.forEach(node => { + nodes.forEach(node => { + // don't rewrite if already upgraded, eg. field LEDS already present + if (U.toArray(node.children).filter(child => child.tagName == "field" && "LEDS" == child.getAttribute("name"))[0]) + return; + // read LEDxx value and assmebly into a new field const leds: string[][] = [[], [], [], [], []]; U.toArray(node.children) .filter(child => child.tagName == "field" && /^LED\d+$/.test(child.getAttribute("name")))