Skip to content

Commit

Permalink
Add a monkey patch for the cash's removeClass to make it work with IE
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Apr 2, 2018
1 parent 94eba6b commit e0b7753
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dist/grapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23676,7 +23676,7 @@ module.exports = function () {
plugins: plugins,

// Will be replaced on build
version: '0.14.7',
version: '0.14.8',

/**
* Initializes an editor based on passed options
Expand Down Expand Up @@ -45162,7 +45162,7 @@ module.exports = Backbone.View.extend({
updateScript: function updateScript(view) {
if (!view.scriptContainer) {
view.scriptContainer = $('<div>');
this.getJsContainer().append(view.scriptContainer.get(0));
this.getJsContainer().appendChild(view.scriptContainer.get(0));
}

var model = view.model;
Expand Down
6 changes: 3 additions & 3 deletions dist/grapes.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grapesjs",
"description": "Free and Open Source Web Builder Framework",
"version": "0.14.7",
"version": "0.14.8",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",
Expand Down
35 changes: 30 additions & 5 deletions src/utils/extender.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject } from 'underscore';
import { isObject, isString, each, isUndefined } from 'underscore';

module.exports = ({ $, Backbone }) => {
if (Backbone) {
Expand Down Expand Up @@ -177,11 +177,36 @@ module.exports = ({ $, Backbone }) => {
return this;
};

(fn.remove = function() {
return this.each(node => {
return node.parentNode && node.parentNode.removeChild(node);
});
// For SVGs in IE
(fn.removeClass = function(c) {
if (!arguments.length) {
return this.attr('class', '');
}
const classes = isString(c) && c.match(/\S+/g);
return classes
? this.each(function(el) {
each(classes, function(c) {
if (el.classList) {
el.classList.remove(c);
} else {
const val = el.className;
const bval = el.className.baseVal;

if (!isUndefined(bval)) {
val.baseVal = bval.replace(c, '');
} else {
el.className = val.replace(c, '');
}
}
});
})
: this;
}),
(fn.remove = function() {
return this.each(node => {
return node.parentNode && node.parentNode.removeChild(node);
});
}),
// For spectrum compatibility
(fn.bind = function(ev, h) {
return this.on(ev, h);
Expand Down

0 comments on commit e0b7753

Please sign in to comment.