Skip to content

Commit

Permalink
Fix #28 - rename IE to isImportNodeLengthWrong
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed Nov 20, 2020
1 parent 19a962b commit 10dc90c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cjs/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ exports.createTreeWalker = createTreeWalker;
exports.importNode = importNode;

// this "hack" tells the library if the browser is IE11 or old Edge
const IE = importNode.length != 1;
const isImportNodeLengthWrong = importNode.length != 1;

// IE11 and old Edge discard empty nodes when cloning, potentially
// resulting in broken paths to find updates. The workaround here
// is to import once, upfront, the fragment that will be cloned
// later on, so that paths are retrieved from one already parsed,
// hence without missing child nodes once re-cloned.
const createFragment = IE ?
const createFragment = isImportNodeLengthWrong ?
(text, type) => importNode.call(
document,
createContent(text, type),
Expand All @@ -45,7 +45,7 @@ exports.createFragment = createFragment;
// IE11 and old Edge have a different createTreeWalker signature that
// has been deprecated in other browsers. This export is needed only
// to guarantee the TreeWalker doesn't show warnings and, ultimately, works
const createWalker = IE ?
const createWalker = isImportNodeLengthWrong ?
fragment => createTreeWalker.call(document, fragment, 1 | 128, null, false) :
fragment => createTreeWalker.call(document, fragment, 1 | 128);
exports.createWalker = createWalker;
6 changes: 3 additions & 3 deletions esm/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ const {createTreeWalker, importNode} = document;
export {createTreeWalker, importNode};

// this "hack" tells the library if the browser is IE11 or old Edge
const IE = importNode.length != 1;
const isImportNodeLengthWrong = importNode.length != 1;

// IE11 and old Edge discard empty nodes when cloning, potentially
// resulting in broken paths to find updates. The workaround here
// is to import once, upfront, the fragment that will be cloned
// later on, so that paths are retrieved from one already parsed,
// hence without missing child nodes once re-cloned.
export const createFragment = IE ?
export const createFragment = isImportNodeLengthWrong ?
(text, type) => importNode.call(
document,
createContent(text, type),
Expand All @@ -40,6 +40,6 @@ export const createFragment = IE ?
// IE11 and old Edge have a different createTreeWalker signature that
// has been deprecated in other browsers. This export is needed only
// to guarantee the TreeWalker doesn't show warnings and, ultimately, works
export const createWalker = IE ?
export const createWalker = isImportNodeLengthWrong ?
fragment => createTreeWalker.call(document, fragment, 1 | 128, null, false) :
fragment => createTreeWalker.call(document, fragment, 1 | 128);
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,19 +401,19 @@ window.uhtml = (function (exports) {
createTreeWalker = _document.createTreeWalker,
importNode = _document.importNode;

var IE = importNode.length != 1; // IE11 and old Edge discard empty nodes when cloning, potentially
var isImportNodeLengthWrong = importNode.length != 1; // IE11 and old Edge discard empty nodes when cloning, potentially
// resulting in broken paths to find updates. The workaround here
// is to import once, upfront, the fragment that will be cloned
// later on, so that paths are retrieved from one already parsed,
// hence without missing child nodes once re-cloned.

var createFragment = IE ? function (text, type) {
var createFragment = isImportNodeLengthWrong ? function (text, type) {
return importNode.call(document, createContent(text, type), true);
} : createContent; // IE11 and old Edge have a different createTreeWalker signature that
// has been deprecated in other browsers. This export is needed only
// to guarantee the TreeWalker doesn't show warnings and, ultimately, works

var createWalker = IE ? function (fragment) {
var createWalker = isImportNodeLengthWrong ? function (fragment) {
return createTreeWalker.call(document, fragment, 1 | 128, null, false);
} : function (fragment) {
return createTreeWalker.call(document, fragment, 1 | 128);
Expand Down

0 comments on commit 10dc90c

Please sign in to comment.