diff --git a/core/block_drag_surface.js b/core/block_drag_surface.js index a9c46c244..d80924d90 100644 --- a/core/block_drag_surface.js +++ b/core/block_drag_surface.js @@ -99,7 +99,7 @@ Blockly.BlockDragSurfaceSvg.prototype.createDom = function() { this.SVG_ = Blockly.utils.dom.createSvgElement('svg', { 'xmlns': Blockly.utils.dom.SVG_NS, 'xmlns:html': Blockly.utils.dom.HTML_NS, - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklyBlockDragSurface' }, this.container_); diff --git a/core/comment.js b/core/comment.js index f587cc78d..80e4ed1d1 100644 --- a/core/comment.js +++ b/core/comment.js @@ -31,7 +31,7 @@ goog.require('Blockly.Events'); goog.require('Blockly.Events.BlockChange'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Icon'); -goog.provide('Blockly.utils.dom'); +goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.userAgent'); diff --git a/core/field_angle.js b/core/field_angle.js index 6c44deb8b..36ca268dc 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -28,7 +28,7 @@ goog.provide('Blockly.FieldAngle'); goog.require('Blockly.DropDownDiv'); goog.require('Blockly.FieldTextInput'); -goog.provide('Blockly.utils.dom'); +goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.math'); goog.require('Blockly.utils.userAgent'); @@ -177,9 +177,9 @@ Blockly.FieldAngle.prototype.showEditor_ = function() { // Build the SVG DOM. var svg = Blockly.utils.dom.createSvgElement('svg', { - 'xmlns': 'http://www.w3.org/2000/svg', - 'xmlns:html': 'http://www.w3.org/1999/xhtml', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'xmlns': Blockly.utils.dom.SVG_NS, + 'xmlns:html': Blockly.utils.dom.HTML_NS, + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'height': (Blockly.FieldAngle.HALF * 2) + 'px', 'width': (Blockly.FieldAngle.HALF * 2) + 'px' diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 610fb3c8d..be5ccfaad 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -476,7 +476,7 @@ Blockly.FieldDropdown.prototype.render_ = function() { */ Blockly.FieldDropdown.prototype.renderSelectedImage_ = function() { this.imageElement_.setAttributeNS( - 'http://www.w3.org/1999/xlink', 'xlink:href', this.imageJson_.src); + Blockly.utils.dom.XLINK_NS, 'xlink:href', this.imageJson_.src); this.imageElement_.setAttribute('height', this.imageJson_.height); this.imageElement_.setAttribute('width', this.imageJson_.width); diff --git a/core/field_image.js b/core/field_image.js index 098ff1d2a..cc4ba0617 100644 --- a/core/field_image.js +++ b/core/field_image.js @@ -125,7 +125,7 @@ Blockly.FieldImage.prototype.initView = function() { 'alt': this.text_ }, this.fieldGroup_); - this.imageElement_.setAttributeNS('http://www.w3.org/1999/xlink', + this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.value_); }; @@ -161,7 +161,7 @@ Blockly.FieldImage.prototype.doClassValidation_ = function(newValue) { Blockly.FieldImage.prototype.doValueUpdate_ = function(newValue) { this.value_ = newValue; if (this.imageElement_) { - this.imageElement_.setAttributeNS('http://www.w3.org/1999/xlink', + this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.value_ || ''); } }; diff --git a/core/grid.js b/core/grid.js index 2e78cb819..f8d7bee74 100644 --- a/core/grid.js +++ b/core/grid.js @@ -27,7 +27,7 @@ goog.provide('Blockly.Grid'); -goog.provide('Blockly.utils.dom'); +goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.userAgent'); diff --git a/core/inject.js b/core/inject.js index 61df917db..e40d110e5 100644 --- a/core/inject.js +++ b/core/inject.js @@ -113,9 +113,9 @@ Blockly.createDom_ = function(container, options) { */ var svg = Blockly.utils.dom.createSvgElement('svg', { - 'xmlns': 'http://www.w3.org/2000/svg', - 'xmlns:html': 'http://www.w3.org/1999/xhtml', - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'xmlns': Blockly.utils.dom.SVG_NS, + 'xmlns:html': Blockly.utils.dom.HTML_NS, + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklySvg' }, container); diff --git a/core/trashcan.js b/core/trashcan.js index 035ff9e77..d97c1ceae 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -247,7 +247,7 @@ Blockly.Trashcan.prototype.createDom = function() { 'clip-path': 'url(#blocklyTrashBodyClipPath' + rnd + ')' }, this.svgGroup_); - body.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + body.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); clip = Blockly.utils.dom.createSvgElement('clipPath', @@ -264,7 +264,7 @@ Blockly.Trashcan.prototype.createDom = function() { 'clip-path': 'url(#blocklyTrashLidClipPath' + rnd + ')' }, this.svgGroup_); - this.svgLid_.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + this.svgLid_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); Blockly.bindEventWithChecks_(this.svgGroup_, 'mouseup', this, this.click); diff --git a/core/utils/dom.js b/core/utils/dom.js index eff026f0d..3a9b0013e 100644 --- a/core/utils/dom.js +++ b/core/utils/dom.js @@ -45,6 +45,12 @@ Blockly.utils.dom.SVG_NS = 'http://www.w3.org/2000/svg'; */ Blockly.utils.dom.HTML_NS = 'http://www.w3.org/1999/xhtml'; +/** + * Required name space for XLINK elements. + * @const + */ +Blockly.utils.dom.XLINK_NS = 'http://www.w3.org/1999/xlink'; + /** * Helper method for creating SVG elements. * @param {string} name Element's tag name. diff --git a/core/warning.js b/core/warning.js index 551bda5df..dae39898c 100644 --- a/core/warning.js +++ b/core/warning.js @@ -30,7 +30,7 @@ goog.require('Blockly.Bubble'); goog.require('Blockly.Events'); goog.require('Blockly.Events.Ui'); goog.require('Blockly.Icon'); -goog.provide('Blockly.utils.dom'); +goog.require('Blockly.utils.dom'); /** diff --git a/core/workspace_drag_surface_svg.js b/core/workspace_drag_surface_svg.js index fbf7c3245..6c8f567aa 100644 --- a/core/workspace_drag_surface_svg.js +++ b/core/workspace_drag_surface_svg.js @@ -90,7 +90,7 @@ Blockly.WorkspaceDragSurfaceSvg.prototype.createDom = function() { { 'xmlns': Blockly.utils.dom.SVG_NS, 'xmlns:html': Blockly.utils.dom.HTML_NS, - 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + 'xmlns:xlink': Blockly.utils.dom.XLINK_NS, 'version': '1.1', 'class': 'blocklyWsDragSurface blocklyOverflowVisible' }, null); diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 3c1e85e82..46566b441 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -216,7 +216,7 @@ Blockly.ZoomControls.prototype.createZoomOutSvg_ = function(rnd) { 'clip-path': 'url(#blocklyZoomoutClipPath' + rnd + ')' }, this.zoomOutGroup_); - zoomoutSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + zoomoutSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', ws.options.pathToMedia + Blockly.SPRITE.url); // Attach listener. @@ -269,7 +269,7 @@ Blockly.ZoomControls.prototype.createZoomInSvg_ = function(rnd) { 'clip-path': 'url(#blocklyZoominClipPath' + rnd + ')' }, this.zoomInGroup_); - zoominSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + zoominSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', ws.options.pathToMedia + Blockly.SPRITE.url); // Attach listener. @@ -321,7 +321,7 @@ Blockly.ZoomControls.prototype.createZoomResetSvg_ = function(rnd) { 'clip-path': 'url(#blocklyZoomresetClipPath' + rnd + ')' }, this.zoomResetGroup_); - zoomresetSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', + zoomresetSvg.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href', ws.options.pathToMedia + Blockly.SPRITE.url); // Attach event listeners.