Upgrade the device_note block (#1593)
This commit is contained in:
parent
ec45f388df
commit
a787fffbb7
@ -774,14 +774,17 @@ namespace pxt.editor {
|
|||||||
if (b) b.setAttribute("name", "ARG1");
|
if (b) b.setAttribute("name", "ARG1");
|
||||||
});
|
});
|
||||||
|
|
||||||
// math_number_minmax
|
renameField(dom, "math_number_minmax", "NUM", "SLIDER");
|
||||||
U.toArray(dom.querySelectorAll("block[type=math_number_minmax]"))
|
renameField(dom, "device_note", "note", "name");
|
||||||
.concat(U.toArray(dom.querySelectorAll("shadow[type=math_number_minmax]")))
|
}
|
||||||
|
|
||||||
|
function renameField(dom: Element, blockType: string, oldName: string, newName: string) {
|
||||||
|
U.toArray(dom.querySelectorAll(`block[type=${blockType}]`))
|
||||||
|
.concat(U.toArray(dom.querySelectorAll(`shadow[type=${blockType}]`)))
|
||||||
.forEach(node => {
|
.forEach(node => {
|
||||||
// Change the name of the NUM field to SLIDER
|
const thefield = getField(node, oldName);
|
||||||
const numField = getField(node, "NUM");
|
if (thefield) {
|
||||||
if (numField) {
|
thefield.setAttribute("name", newName);
|
||||||
numField.setAttribute("name", "SLIDER");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user