Skip to content

Commit

Permalink
removed unnecessary checks due cleaner output produced by domtagger
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Giammarchi committed Dec 17, 2018
1 parent 9dd6030 commit 7086b09
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 50 deletions.
21 changes: 5 additions & 16 deletions cjs/hyper/wire.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';
const WeakMap = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/weakmap'));
const trim = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('@ungap/trim'));

const {ELEMENT_NODE} = require('../shared/constants.js');
const Wire = (m => m.__esModule ? /* istanbul ignore next */ m.default : /* istanbul ignore next */ m)(require('../classes/Wire.js'));

const {Tagger} = require('../objects/Updates.js');
const {reArguments} = require('../shared/utils.js');
const {reArguments, slice} = require('../shared/utils.js');

// all wires used per each context
const wires = new WeakMap;
Expand Down Expand Up @@ -69,24 +67,15 @@ const weakly = (obj, type) => {
// stay associated with the original interpolation.
// To prevent hyperHTML from forgetting about a fragment's sub-nodes,
// fragments are instead returned as an Array of nodes or, if there's only one entry,
// as a single referenced node which, unlike framents, will indeed persist
// as a single referenced node which, unlike fragments, will indeed persist
// wire content throughout multiple renderings.
// The initial fragment, at this point, would be used as unique reference to this
// array of nodes or to this single referenced node.
const wireContent = node => {
const childNodes = node.childNodes;
const length = childNodes.length;
const wireNodes = [];
for (let i = 0; i < length; i++) {
let child = childNodes[i];
if (
child.nodeType === ELEMENT_NODE ||
trim.call(child.textContent).length !== 0
) {
wireNodes.push(child);
}
}
return wireNodes.length === 1 ? wireNodes[0] : new Wire(wireNodes);
return childNodes.length === 1 ?
childNodes[0] :
new Wire(slice.call(childNodes, 0));
};

exports.content = content;
Expand Down
2 changes: 1 addition & 1 deletion esm.js

Large diffs are not rendered by default.

21 changes: 5 additions & 16 deletions esm/hyper/wire.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import WeakMap from '@ungap/weakmap';
import trim from '@ungap/trim';

import {ELEMENT_NODE} from '../shared/constants.js';
import Wire from '../classes/Wire.js';

import {Tagger} from '../objects/Updates.js';
import {reArguments} from '../shared/utils.js';
import {reArguments, slice} from '../shared/utils.js';

// all wires used per each context
const wires = new WeakMap;
Expand Down Expand Up @@ -68,24 +66,15 @@ const weakly = (obj, type) => {
// stay associated with the original interpolation.
// To prevent hyperHTML from forgetting about a fragment's sub-nodes,
// fragments are instead returned as an Array of nodes or, if there's only one entry,
// as a single referenced node which, unlike framents, will indeed persist
// as a single referenced node which, unlike fragments, will indeed persist
// wire content throughout multiple renderings.
// The initial fragment, at this point, would be used as unique reference to this
// array of nodes or to this single referenced node.
const wireContent = node => {
const childNodes = node.childNodes;
const length = childNodes.length;
const wireNodes = [];
for (let i = 0; i < length; i++) {
let child = childNodes[i];
if (
child.nodeType === ELEMENT_NODE ||
trim.call(child.textContent).length !== 0
) {
wireNodes.push(child);
}
}
return wireNodes.length === 1 ? wireNodes[0] : new Wire(wireNodes);
return childNodes.length === 1 ?
childNodes[0] :
new Wire(slice.call(childNodes, 0));
};

export { content, weakly };
Expand Down
17 changes: 2 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1202,11 +1202,6 @@ var hyperHTML = (function (document) {
}();

var G = document.defaultView;

// Node.CONSTANTS
// 'cause some engine has no global Node defined
// (i.e. Node, NativeScript, basicHTML ... )
var ELEMENT_NODE$1 = 1;
var DOCUMENT_FRAGMENT_NODE$1 = 11;

// SVG related constants
Expand Down Expand Up @@ -1641,21 +1636,13 @@ var hyperHTML = (function (document) {
// stay associated with the original interpolation.
// To prevent hyperHTML from forgetting about a fragment's sub-nodes,
// fragments are instead returned as an Array of nodes or, if there's only one entry,
// as a single referenced node which, unlike framents, will indeed persist
// as a single referenced node which, unlike fragments, will indeed persist
// wire content throughout multiple renderings.
// The initial fragment, at this point, would be used as unique reference to this
// array of nodes or to this single referenced node.
var wireContent = function wireContent(node) {
var childNodes = node.childNodes;
var length = childNodes.length;
var wireNodes = [];
for (var i = 0; i < length; i++) {
var child = childNodes[i];
if (child.nodeType === ELEMENT_NODE$1 || trim.call(child.textContent).length !== 0) {
wireNodes.push(child);
}
}
return wireNodes.length === 1 ? wireNodes[0] : new Wire(wireNodes);
return childNodes.length === 1 ? childNodes[0] : new Wire(slice.call(childNodes, 0));
};

// a weak collection of contexts that
Expand Down
Loading

0 comments on commit 7086b09

Please sign in to comment.