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");
});
// math_number_minmax
U.toArray(dom.querySelectorAll("block[type=math_number_minmax]"))
.concat(U.toArray(dom.querySelectorAll("shadow[type=math_number_minmax]")))
renameField(dom, "math_number_minmax", "NUM", "SLIDER");
renameField(dom, "device_note", "note", "name");
}
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 => {
// Change the name of the NUM field to SLIDER
const numField = getField(node, "NUM");
if (numField) {
numField.setAttribute("name", "SLIDER");
const thefield = getField(node, oldName);
if (thefield) {
thefield.setAttribute("name", newName);
}
});
}