mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
Merge pull request #1005 from rachel-fenichel/bugfix/IE10_offsets
RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttrib…
This commit is contained in:
@@ -28,8 +28,9 @@ goog.provide('Blockly.BlockSvg');
|
||||
|
||||
goog.require('Blockly.Block');
|
||||
goog.require('Blockly.ContextMenu');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.RenderedConnection');
|
||||
goog.require('Blockly.Touch');
|
||||
goog.require('Blockly.utils');
|
||||
goog.require('goog.Timer');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom');
|
||||
@@ -425,7 +426,7 @@ Blockly.BlockSvg.prototype.moveOffDragSurface_ = function() {
|
||||
* @private
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.clearTransformAttributes_ = function() {
|
||||
this.getSvgRoot().removeAttribute('transform');
|
||||
Blockly.utils.removeAttribute(this.getSvgRoot(), 'transform');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1569,7 +1570,7 @@ Blockly.BlockSvg.prototype.setHighlighted = function(highlighted) {
|
||||
'url(#' + this.workspace.options.embossFilterId + ')');
|
||||
this.svgPathLight_.style.display = 'none';
|
||||
} else {
|
||||
this.svgPath_.removeAttribute('filter');
|
||||
Blockly.utils.removeAttribute(this.svgPath_, 'filter');
|
||||
delete this.svgPathLight_.style.display;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,6 +38,23 @@ goog.require('goog.events.BrowserFeature');
|
||||
goog.require('goog.math.Coordinate');
|
||||
goog.require('goog.userAgent');
|
||||
|
||||
/**
|
||||
* Remove an attribute from a element even if it's in IE 10.
|
||||
* Similar to Element.removeAttribute() but it works on SVG elements in IE 10.
|
||||
* Sets the attribute to null in IE 10, which treats removeAttribute as a no-op
|
||||
* if it's called on an SVG element.
|
||||
* @param {!Element} element DOM element to remove attribute from.
|
||||
* @param {string} attributeName Name of attribute to remove.
|
||||
*/
|
||||
Blockly.utils.removeAttribute = function(element, attributeName) {
|
||||
// goog.userAgent.isVersion is deprecated, but the replacement is
|
||||
// goog.userAgent.isVersionOrHigher.
|
||||
if (goog.userAgent.IE && goog.userAgent.isVersion('10.0')) {
|
||||
element.setAttribute(attributeName, null);
|
||||
} else {
|
||||
element.removeAttribute(attributeName);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a CSS class to a element.
|
||||
@@ -80,7 +97,7 @@ Blockly.utils.removeClass = function(element, className) {
|
||||
if (classList.length) {
|
||||
element.setAttribute('class', classList.join(' '));
|
||||
} else {
|
||||
element.removeAttribute('class');
|
||||
Blockly.utils.removeAttribute(element, 'class');
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user