diff --git a/src/grapesjs/index.js b/src/grapesjs/index.js index 81a82be78..1a24b3235 100644 --- a/src/grapesjs/index.js +++ b/src/grapesjs/index.js @@ -1,5 +1,8 @@ import $ from 'cash-dom'; import { defaults } from 'underscore'; +import polyfills from 'utils/polyfills'; + +polyfills(); module.exports = (() => { const defaultConfig = require('./config/config'); diff --git a/src/utils/Sorter.js b/src/utils/Sorter.js index c12e5cb84..9ef15edba 100644 --- a/src/utils/Sorter.js +++ b/src/utils/Sorter.js @@ -925,7 +925,7 @@ module.exports = Backbone.View.extend({ var dragHelper = this.dragHelper; if(dragHelper) { - dragHelper.remove(); + dragHelper.parentNode.removeChild(dragHelper); this.dragHelper = null; } diff --git a/src/utils/polyfills.js b/src/utils/polyfills.js new file mode 100644 index 000000000..eb5449044 --- /dev/null +++ b/src/utils/polyfills.js @@ -0,0 +1,38 @@ +/** + * File made for IE/Edge support + * https://github.com/artf/grapesjs/issues/214 + */ + +export default () => { + + /** + * Check if IE/Edge + * @return {Boolean} + */ + const isIE = () => { + let match; + const agent = window.navigator.userAgent; + const rules = [ + [ 'edge', /Edge\/([0-9\._]+)/ ], + [ 'ie', /MSIE\s(7\.0)/ ], + [ 'ie', /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/ ], + [ 'ie', /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/ ], + ]; + + for (let i = 0; i < rules.length; i++) { + const rule = rules[i]; + match = rule[1].exec(agent); + if (match) break; + } + + return !!match; + } + + if (isIE()) { + const originalCreateHTMLDocument = DOMImplementation.prototype.createHTMLDocument + DOMImplementation.prototype.createHTMLDocument = (title) => { + if (!title) title = ''; + return originalCreateHTMLDocument.apply(document.implementation, [title]); + } + } +}