Skip to content

Commit

Permalink
IE11 support for shady css
Browse files Browse the repository at this point in the history
  • Loading branch information
eavichay committed May 4, 2017
1 parent 187244f commit 697b64e
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 9 deletions.
48 changes: 44 additions & 4 deletions Slim.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ var Slim = function (_CustomElement2) {
});
}

/**
* Polyfill for IE11 support
* @param target
*/

}, {
key: 'removeChild',
value: function removeChild(target) {
if (target.remove) {
target.remove();
}
if (!target.remove && target.parentNode) {
target.parentNode.removeChild(target);
if (target._boundChildren) {
target._boundChildren.forEach(function (child) {
if (child.__ieClone) {
Slim.removeChild(child.__ieClone);
}
});
}
}
}

/**
*
* @param source
Expand Down Expand Up @@ -473,15 +496,15 @@ var Slim = function (_CustomElement2) {
if (!value) {
if (descriptor.target.parentNode) {
descriptor.target.insertAdjacentElement('beforeBegin', descriptor.helper);
descriptor.target.remove();
Slim.removeChild(descriptor.target);
}
} else {
if (!descriptor.target.parentNode) {
descriptor.helper.insertAdjacentElement('beforeBegin', descriptor.target);
if (descriptor.target.isSlim) {
descriptor.target.createdCallback();
}
descriptor.helper.remove();
Slim.removeChild(descriptor.helper);
}
}
};
Expand Down Expand Up @@ -716,6 +739,9 @@ var Slim = function (_CustomElement2) {
_this3._bindings[property].executors.forEach(function (fn) {
if (fn.descriptor.type === 'T') {
fn.descriptor.target.innerText = fn.descriptor.target._innerText;
if (fn.descriptor.target.__ieClone) {
fn.descriptor.target.__ieClone.innerText = fn.descriptor.target.innerText;
}
}
});
});
Expand Down Expand Up @@ -964,7 +990,13 @@ var Slim = function (_CustomElement2) {

var customTagName = tag + '[slim-uq="' + uqIndex + '"]';
node.innerText = node.innerText.replace(/\:host/g, customTagName);
// tag-name[slim-uq="[[uq_index]]"]

if (Slim.__isIE11) {
var ieClone = document.createElement('style');
node.__ieClone = ieClone;
ieClone.innerText = node.innerText;
document.head.appendChild(ieClone);
}
}

/**
Expand Down Expand Up @@ -1124,6 +1156,14 @@ try {
Slim.__isWCSupported = false;
}

try {
Slim.__isIE11 = function () {
return !!window['MSInputMethodContext'] && !!document['documentMode'];
}();
} catch (err) {
Slim.__isIE11 = false;
}

if (Slim.__isWCSupported) {
Slim.selectorToArr = function (target, selector) {
return target.querySelectorAll(selector);
Expand Down Expand Up @@ -1174,7 +1214,7 @@ Slim.__initRepeater = function () {
key: 'clearList',
value: function clearList() {
this.clones && this.clones.forEach(function (clone) {
clone.remove();
Slim.removeChild(clone);
});
this.clones = [];
}
Expand Down
Loading

0 comments on commit 697b64e

Please sign in to comment.