Skip to content

Commit 3c39b31

Browse files
committed
replace prepend() calls since they aren't supported in IE11
1 parent e94ee3d commit 3c39b31

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/components/modebar/modebar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ proto.update = function(graphInfo, buttons) {
8888
}
8989

9090
if(fullLayout.modebar.orientation === 'v') {
91-
this.element.prepend(logoGroup);
91+
Lib.prependElement(this.element, logoGroup);
9292
} else {
9393
this.element.appendChild(logoGroup);
9494
}

src/lib/index.js

+13
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,19 @@ lib.removeElement = function(el) {
689689
if(elParent) elParent.removeChild(el);
690690
};
691691

692+
lib.prependElement = function(el) {
693+
var argArr = Array.prototype.slice.call(arguments);
694+
argArr.splice(0, 1);
695+
var docFrag = document.createDocumentFragment();
696+
697+
argArr.forEach(function(argItem) {
698+
var isNode = argItem instanceof Node;
699+
docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
700+
});
701+
702+
el.insertBefore(docFrag, el.firstChild);
703+
};
704+
692705
/**
693706
* for dynamically adding style rules
694707
* makes one stylesheet that contains all rules added

test/jasmine/assets/unpolyfill.js

+12
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,17 @@
1818
].join(' '));
1919
}
2020
});
21+
22+
Object.defineProperty(item, 'prepend', {
23+
configurable: true,
24+
enumerable: true,
25+
writable: true,
26+
value: function remove() {
27+
throw Error([
28+
'test/jasmine/assets/unpolyfill.js error: calling ChildNode.prepend()',
29+
'which is not available in IE.'
30+
].join(' '));
31+
}
32+
});
2133
});
2234
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

0 commit comments

Comments
 (0)