Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function renderEntry(exported) {
if (exported.default) {
exported = exported.default
}
// Assumptions: the entry module either renders the app itself or exports an
// Inferno component (which is either a function or class) or VNode (which has
// a flags property).
if (Object.prototype.toString.call(exported) === '[object Function]') {
vnode = Inferno.createComponentVNode(1 << 1 /* === VNodeFlags.ComponentUnknown */, exported)
}
else if (exported.flags) {
vnode = exported
}
else {
// Assumption: the entry module rendered the app
return
}
Inferno.render(vnode, parent)
}
it('setState should apply state during componentWillReceiveProps', done => {
render(createComponentVNode(VNodeFlags.ComponentClass, TestCWRP, {}), container);
expect(renderCount).toBe(1);
render(
createComponentVNode(VNodeFlags.ComponentClass, TestCWRP, {
foo: 1
}),
container
);
expect(renderCount).toBe(2);
done();
});
});
function renderIntoDocument(input) {
return React.render(createComponentVNode(VNodeFlags.ComponentClass, Wrapper, { children: input }), container);
}
function renderIntoDocument(input) {
return render(createComponentVNode(VNodeFlags.ComponentClass, Wrapper, { children: input }), container);
}
public render() {
const selector = this.selector;
selector.shouldComponentUpdate = false;
if (selector.error) {
throw selector.error;
} else {
return normalizeProps(
createComponentVNode(
VNodeFlags.ComponentUnknown,
WrappedComponent,
this.addExtraProps(selector.props),
null,
withRef ? this.setWrappedInstance : null
)
);
}
}
}
}
if (childLen === 1) {
children = _children;
} else if (childLen > 1) {
children = [];
while (childLen-- > 0) {
children[childLen] = arguments[childLen + 2];
}
}
props.children = children;
if (flags & VNodeFlags.Component) {
return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref);
}
if (flags & VNodeFlags.Text) {
return createTextVNode(children);
}
if (flags & VNodeFlags.Fragment) {
return createFragment(childLen === 1 ? [children] : children, ChildFlags.UnknownChildren, key);
}
return normalizeProps(
createVNode(flags, vNodeToClone.type, className, null, ChildFlags.HasInvalidChildren, combineFrom(vNodeToClone.props, props), key, ref)
);
}
function linkComponent({ location, match }): VNode {
const isActive = !!(getIsActive ? getIsActive(match, location) : match);
return createComponentVNode(
VNodeFlags.ComponentFunction,
Link,
combineFrom(
{
'aria-current': isActive && ariaCurrent,
className: isActive ? [className, activeClassName].filter(filter).join(' ') : className,
onClick,
style: isActive ? combineFrom(style, activeStyle) : style,
to
},
rest
)
);
}
public render({ basename, context, location, ...props }): VNode {
return createComponentVNode(
VNodeFlags.ComponentClass,
Router,
combineFrom(props, {
history: {
action: 'POP',
block: this.handleBlock,
createHref: this.createHref,
go: staticHandler('go'),
goBack: staticHandler('goBack'),
goForward: staticHandler('goForward'),
listen: this.handleListen,
location: stripBasename(basename, createLocation(location)),
push: this.handlePush,
replace: this.handleReplace
}
})
public render(): VNode | null {
const { route } = this.context.router;
const { children } = this.props;
const location = this.props.location || route.location;
if (isInvalid(children)) {
return null;
}
const { match, _child } = extractMatchFromChildren(children, route, location);
if (match) {
return createComponentVNode(_child.flags, _child.type, combineFrom(_child.props, { location, computedMatch: match }));
}
return null;
}
}
VNodeFlags.ComponentFunction,
Link,
combineFrom(
{
'aria-current': isActive && ariaCurrent,
className: isActive ? [className, activeClassName].filter(filter).join(' ') : className,
onClick,
style: isActive ? combineFrom(style, activeStyle) : style,
to
},
rest
)
);
}
return createComponentVNode(VNodeFlags.ComponentClass, Route, {
children: linkComponent as any,
exact,
location: linkLocation,
path: typeof to === 'object' ? to.pathname : to,
strict
});
}