Upgrade the device_note block (#1593)

This commit is contained in:
Richard Knoll 2018-11-05 17:24:00 -08:00 committed by GitHub
parent ec45f388df
commit a787fffbb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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");
} }
}); });
} }