Add Blockly.utils.dom.XLINK_NS

And fix provide/require mixup.
This commit is contained in:
Neil Fraser
2019-06-07 01:51:53 -07:00
committed by Neil Fraser
parent 848d3a3509
commit 98a98bcce6
12 changed files with 26 additions and 20 deletions

View File

@@ -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_);

View File

@@ -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');

View File

@@ -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'

View File

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

View File

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

View File

@@ -27,7 +27,7 @@
goog.provide('Blockly.Grid');
goog.provide('Blockly.utils.dom');
goog.require('Blockly.utils.dom');
goog.require('Blockly.utils.userAgent');

View File

@@ -113,9 +113,9 @@ Blockly.createDom_ = function(container, options) {
</svg>
*/
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);

View File

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

View File

@@ -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.

View File

@@ -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');
/**

View File

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

View File

@@ -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.