From 41e5914bd74c28e76d10ebbae3ae40d605826e2c Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Fri, 27 Sep 2019 12:21:08 -0700 Subject: [PATCH] el.style is readonly in strict mode IE. Fixing crash in IE. (#3119) --- core/components/tree/basenode.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/core/components/tree/basenode.js b/core/components/tree/basenode.js index e2dc06871..c67805330 100644 --- a/core/components/tree/basenode.js +++ b/core/components/tree/basenode.js @@ -606,7 +606,10 @@ Blockly.tree.BaseNode.prototype.toDom = function() { var nonEmptyAndExpanded = this.getExpanded() && this.hasChildren(); var children = document.createElement('div'); - children.style = this.getLineStyle(); + children.style.backgroundPosition = this.getBackgroundPosition(); + if (!nonEmptyAndExpanded) { + children.style.display = 'none'; + } if (nonEmptyAndExpanded) { // children @@ -635,12 +638,10 @@ Blockly.tree.BaseNode.prototype.getPixelIndent_ = function() { * @protected */ Blockly.tree.BaseNode.prototype.getRowDom = function() { - var style = 'padding-' + (this.isRightToLeft() ? 'right' : 'left') + ':' + - this.getPixelIndent_() + 'px'; - var row = document.createElement('div'); row.className = this.getRowClassName(); - row.style = style; + row.style['padding-' + (this.isRightToLeft() ? 'right' : 'left')] = + this.getPixelIndent_() + 'px'; row.appendChild(this.getIconDom()); row.appendChild(this.getLabelDom()); @@ -690,16 +691,6 @@ Blockly.tree.BaseNode.prototype.getCalculatedIconClass = function() { throw Error('unimplemented abstract method'); }; -/** - * @return {string} The line style. - * @protected - */ -Blockly.tree.BaseNode.prototype.getLineStyle = function() { - var nonEmptyAndExpanded = this.getExpanded() && this.hasChildren(); - return 'background-position: ' + this.getBackgroundPosition() + '; ' + - (nonEmptyAndExpanded ? '' : 'display: none'); -}; - /** * @return {string} The background position style value. * @protected