Skip to content

Commit

Permalink
Removed isPromise util, just check for existence of .then function li…
Browse files Browse the repository at this point in the history
…ke we did already in other places
  • Loading branch information
Havunen committed Mar 22, 2016
1 parent 36e15e3 commit b70c6a2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
11 changes: 4 additions & 7 deletions packages/inferno-dom/dist/inferno-dom.es2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ function isNumber(obj) {
return typeof obj === 'number';
}

function isPromise(obj) {
return obj instanceof Promise;
}

var delegatedEventsRegistry = {};

// The issue with this, is that we can't stop the bubbling as we're traversing down the node tree, rather than up it
Expand Down Expand Up @@ -971,12 +967,13 @@ function mountChildren(children, parentDom, namespace, lifecycle, context, insta
if (isArray(children)) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
var childDefined = !isNullOrUndefined(child);

if (isStringOrNumber(child)) {
appendText(child, parentDom, false);
} else if (!isNullOrUndefined(child) && isArray(child)) {
} else if (childDefined && isArray(child)) {
mountChildren(child, parentDom, namespace, lifecycle, context, instance);
} else if (isPromise(child)) {
} else if (childDefined && !isNullOrUndefined(child.then)) {
(function () {
var placeholder = document.createTextNode('');

Expand All @@ -994,7 +991,7 @@ function mountChildren(children, parentDom, namespace, lifecycle, context, insta
} else {
if (isStringOrNumber(children)) {
appendText(children, parentDom, true);
} else if (isPromise(children)) {
} else if (!isNullOrUndefined(children) && !isNullOrUndefined(children.then)) {
(function () {
var placeholder = document.createTextNode('');

Expand Down
11 changes: 4 additions & 7 deletions packages/inferno/dist/inferno-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@
return typeof obj === 'number';
}

function isPromise(obj) {
return obj instanceof Promise;
}

var delegatedEventsRegistry = {};

// The issue with this, is that we can't stop the bubbling as we're traversing down the node tree, rather than up it
Expand Down Expand Up @@ -977,12 +973,13 @@
if (isArray(children)) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
var childDefined = !isNullOrUndefined(child);

if (isStringOrNumber(child)) {
appendText(child, parentDom, false);
} else if (!isNullOrUndefined(child) && isArray(child)) {
} else if (childDefined && isArray(child)) {
mountChildren(child, parentDom, namespace, lifecycle, context, instance);
} else if (isPromise(child)) {
} else if (childDefined && !isNullOrUndefined(child.then)) {
(function () {
var placeholder = document.createTextNode('');

Expand All @@ -1000,7 +997,7 @@
} else {
if (isStringOrNumber(children)) {
appendText(children, parentDom, true);
} else if (isPromise(children)) {
} else if (!isNullOrUndefined(children) && !isNullOrUndefined(children.then)) {
(function () {
var placeholder = document.createTextNode('');

Expand Down
2 changes: 1 addition & 1 deletion packages/inferno/dist/inferno-dom.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/DOM/mounting.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray, isStringOrNumber, isFunction, isNullOrUndefined, addChildrenToProps, isStatefulComponent, isString, isInvalidNode, isPromise } from '../core/utils';
import { isArray, isStringOrNumber, isFunction, isNullOrUndefined, addChildrenToProps, isStatefulComponent, isString, isInvalidNode } from '../core/utils';
import { recyclingEnabled, recycle } from './recycling';
import { appendText, createElement, SVGNamespace, MathNamespace } from './utils';
import { patchAttribute, patchStyle } from './patching';
Expand All @@ -10,12 +10,13 @@ export function mountChildren(children, parentDom, namespace, lifecycle, context
if (isArray(children)) {
for (let i = 0; i < children.length; i++) {
const child = children[i];
const childDefined = !isNullOrUndefined(child);

if (isStringOrNumber(child)) {
appendText(child, parentDom, false);
} else if (!isNullOrUndefined(child) && isArray(child)) {
} else if (childDefined && isArray(child)) {
mountChildren(child, parentDom, namespace, lifecycle, context, instance);
} else if (isPromise(child)) {
} else if (childDefined && !isNullOrUndefined(child.then)) {
const placeholder = document.createTextNode('');

child.then(node => {
Expand All @@ -31,7 +32,7 @@ export function mountChildren(children, parentDom, namespace, lifecycle, context
} else {
if (isStringOrNumber(children)) {
appendText(children, parentDom, true);
} else if (isPromise(children)) {
} else if (!isNullOrUndefined(children) && !isNullOrUndefined(children.then)) {
const placeholder = document.createTextNode('');

children.then(node => {
Expand Down
3 changes: 0 additions & 3 deletions src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,3 @@ export function isAttrAComponentHook(hook) {
|| hook === 'onComponentDidUpdate';
}

export function isPromise(obj) {
return obj instanceof Promise;
}

0 comments on commit b70c6a2

Please sign in to comment.