mirror of
https://github.com/google/blockly.git
synced 2026-01-06 08:30:13 +01:00
chore: Remove radix from parseInt, simplify Blockly.utils.dom methods, use Unicode characters. (#6441)
* chore: remove radix from parseInt Previously any number starting with '0' would be parsed as octal if the radix was left blank. But this was changed years ago. It is no longer needed to specify a radix. * chore: 'ID' is identification 'id' is a part of Freud's brain. * Use Unicode characters instead of codes This is in line with the current style guide. * Simplify Blockly.utils.dom methods. classList add/remove/has supports SVG elements in all browsers Blockly supports (i.e. not IE).
This commit is contained in:
12
core/xml.ts
12
core/xml.ts
@@ -459,14 +459,12 @@ export function domToWorkspace(xml: Element, workspace: Workspace): string[] {
|
||||
// AnyDuringMigration because: Argument of type 'string | null' is not
|
||||
// assignable to parameter of type 'string'.
|
||||
const blockX = xmlChildElement.hasAttribute('x') ?
|
||||
parseInt(
|
||||
xmlChildElement.getAttribute('x') as AnyDuringMigration, 10) :
|
||||
parseInt(xmlChildElement.getAttribute('x') as AnyDuringMigration) :
|
||||
10;
|
||||
// AnyDuringMigration because: Argument of type 'string | null' is not
|
||||
// assignable to parameter of type 'string'.
|
||||
const blockY = xmlChildElement.hasAttribute('y') ?
|
||||
parseInt(
|
||||
xmlChildElement.getAttribute('y') as AnyDuringMigration, 10) :
|
||||
parseInt(xmlChildElement.getAttribute('y') as AnyDuringMigration) :
|
||||
10;
|
||||
if (!isNaN(blockX) && !isNaN(blockY)) {
|
||||
block.moveBy(workspace.RTL ? width - blockX : blockX, blockY);
|
||||
@@ -747,12 +745,10 @@ function applyCommentTagNodes(xmlChildren: Element[], block: Block) {
|
||||
const pinned = xmlChild.getAttribute('pinned') === 'true';
|
||||
// AnyDuringMigration because: Argument of type 'string | null' is not
|
||||
// assignable to parameter of type 'string'.
|
||||
const width =
|
||||
parseInt(xmlChild.getAttribute('w') as AnyDuringMigration, 10);
|
||||
const width = parseInt(xmlChild.getAttribute('w') as AnyDuringMigration);
|
||||
// AnyDuringMigration because: Argument of type 'string | null' is not
|
||||
// assignable to parameter of type 'string'.
|
||||
const height =
|
||||
parseInt(xmlChild.getAttribute('h') as AnyDuringMigration, 10);
|
||||
const height = parseInt(xmlChild.getAttribute('h') as AnyDuringMigration);
|
||||
|
||||
block.setCommentText(text);
|
||||
block.commentModel.pinned = pinned;
|
||||
|
||||
Reference in New Issue
Block a user