Fixed #481: A polyfill required `DocumentType` which is not defined in all environments

This commit is contained in:
jos 2017-11-15 10:52:45 +01:00
parent 42ede262d1
commit 40e4ac9302
2 changed files with 10 additions and 4 deletions

View File

@ -13,6 +13,8 @@ https://github.com/josdejong/jsoneditor
in `text` and `code` mode.
- Implemented repairing JSON objects containing special white space
characters like non-breaking space.
- Fixed #481: A polyfill required `DocumentType` which is not defined
in all environments.
## 2017-09-16, version 5.9.6

View File

@ -872,8 +872,8 @@ exports.getInputSelection = function(el) {
if (typeof Element !== 'undefined') {
// Polyfill for array remove
(function (arr) {
arr.forEach(function (item) {
(function () {
function polyfill (item) {
if (item.hasOwnProperty('remove')) {
return;
}
@ -886,8 +886,12 @@ if (typeof Element !== 'undefined') {
this.parentNode.removeChild(this);
}
});
});
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
}
if (typeof Element !== 'undefined') { polyfill(Element.prototype); }
if (typeof CharacterData !== 'undefined') { polyfill(CharacterData.prototype); }
if (typeof DocumentType !== 'undefined') { polyfill(DocumentType.prototype); }
})();
}