handle rename map
This commit is contained in:
parent
c231b7f51e
commit
cd703111a4
@ -481,10 +481,10 @@ namespace pxt.editor {
|
|||||||
*/
|
*/
|
||||||
const varids: pxt.Map<string> = {};
|
const varids: pxt.Map<string> = {};
|
||||||
|
|
||||||
function addField(node: Element, name: string) {
|
function addField(node: Element, renameMap: pxt.Map<string>, name: string) {
|
||||||
const f = node.ownerDocument.createElement("field");
|
const f = node.ownerDocument.createElement("field");
|
||||||
f.setAttribute("name","HANDLER_" + name)
|
f.setAttribute("name", "HANDLER_" + name)
|
||||||
f.setAttribute("id", varids[name]);
|
f.setAttribute("id", varids[renameMap[name] || name]);
|
||||||
f.appendChild(node.ownerDocument.createTextNode(name));
|
f.appendChild(node.ownerDocument.createTextNode(name));
|
||||||
node.appendChild(f);
|
node.appendChild(f);
|
||||||
}
|
}
|
||||||
@ -499,19 +499,19 @@ namespace pxt.editor {
|
|||||||
case "receivedNumber":
|
case "receivedNumber":
|
||||||
node.setAttribute("type", "radio_on_number");
|
node.setAttribute("type", "radio_on_number");
|
||||||
node.removeChild(node.querySelector("field[name=receivedNumber]"));
|
node.removeChild(node.querySelector("field[name=receivedNumber]"));
|
||||||
addField(node, "receivedNumber");
|
addField(node, renameMap, "receivedNumber");
|
||||||
break;
|
break;
|
||||||
case "receivedString,receivedNumber":
|
case "receivedString,receivedNumber":
|
||||||
node.setAttribute("type", "radio_on_value");
|
node.setAttribute("type", "radio_on_value");
|
||||||
node.removeChild(node.querySelector("field[name=receivedNumber]"));
|
node.removeChild(node.querySelector("field[name=receivedNumber]"));
|
||||||
node.removeChild(node.querySelector("field[name=receivedString]"));
|
node.removeChild(node.querySelector("field[name=receivedString]"));
|
||||||
addField(node, "name");
|
addField(node, renameMap, "name");
|
||||||
addField(node, "value");
|
addField(node, renameMap, "value");
|
||||||
break;
|
break;
|
||||||
case "receivedString":
|
case "receivedString":
|
||||||
node.setAttribute("type", "radio_on_string");
|
node.setAttribute("type", "radio_on_string");
|
||||||
node.removeChild(node.querySelector("field[name=receivedString]"));
|
node.removeChild(node.querySelector("field[name=receivedString]"));
|
||||||
addField(node, "receivedString");
|
addField(node, renameMap, "receivedString");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
node.removeChild(mutation);
|
node.removeChild(mutation);
|
||||||
|
Loading…
Reference in New Issue
Block a user