Skip to content

Commit

Permalink
refactor: rename static children (QwikDev#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Mar 10, 2022
1 parent 3852547 commit 8028547
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/core/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ export type RenderableProps<P, RefType = any> = P & Readonly<{
// @public (undocumented)
export const setPlatform: (doc: Document, plt: CorePlatform) => CorePlatform;

// @public (undocumented)
export const SkipRerender: FunctionComponent<{}>;

// @public (undocumented)
export const Slot: FunctionComponent<{
name?: string;
children?: any;
}>;

// @public (undocumented)
export const StaticChildren: FunctionComponent<{}>;

// @public (undocumented)
export function useDocument(): Document;

Expand Down
2 changes: 1 addition & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type { PromiseValue } from './render/jsx/async.public';
// JSX Runtime
//////////////////////////////////////////////////////////////////////////////////////////
export { h } from './render/jsx/factory';
export { Host, StaticChildren } from './render/jsx/host.public';
export { Host, SkipRerender } from './render/jsx/host.public';
export { Slot } from './render/jsx/slot.public';
export { Fragment, jsx, jsxDEV, jsxs } from './render/jsx/jsx-runtime';
export type {
Expand Down
8 changes: 4 additions & 4 deletions src/core/render/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { assertDefined, assertEqual } from '../assert/assert';
import { NodeType } from '../util/types';
import { intToStr } from '../object/store';
import { EMPTY_ARRAY } from '../util/flyweight';
import { StaticChildren } from './jsx/host.public';
import { SkipRerender } from './jsx/host.public';
import { logDebug, logError } from '../util/log';

type KeyToIndexMap = { [key: string]: number };
Expand Down Expand Up @@ -59,7 +59,7 @@ export function smartUpdateChildren(
mode: ChildrenMode,
isSvg: boolean
) {
if (ch.length === 1 && ch[0].type === StaticChildren) {
if (ch.length === 1 && ch[0].type === SkipRerender) {
if (elm.firstChild !== null) {
return;
}
Expand Down Expand Up @@ -239,7 +239,7 @@ export function patchVnode(
return;
}

if (tag === Host || tag === StaticChildren) {
if (tag === Host || tag === SkipRerender) {
return;
}

Expand Down Expand Up @@ -472,7 +472,7 @@ function createElm(ctx: RenderContext, vnode: JSXNode, isSvg: boolean): ValueOrP
return then(wait, () => {
let children = vnode.children;
if (children.length > 0) {
if (children.length === 1 && children[0].type === StaticChildren) {
if (children.length === 1 && children[0].type === SkipRerender) {
children = children[0].children;
}
const slotMap = isComponent ? getSlots(componentCtx, elm) : undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/core/render/jsx/host.public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export const Host: FunctionComponent<Record<string, any>> = { __brand__: 'host'
/**
* @public
*/
export const StaticChildren: FunctionComponent<{}> = { __brand__: 'skip' } as any;
export const SkipRerender: FunctionComponent<{}> = { __brand__: 'skip' } as any;
4 changes: 2 additions & 2 deletions src/core/render/jsx/jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { FunctionComponent, JSXNode } from './types/jsx-node';
import type { QwikJSX } from './types/jsx-qwik';
import { qDev } from '../../util/qdev';
import { Host, StaticChildren } from './host.public';
import { Host, SkipRerender } from './host.public';
import { EMPTY_ARRAY } from '../../util/flyweight';
import { logWarn } from '../../util/log';

Expand Down Expand Up @@ -47,7 +47,7 @@ export function processNode(node: any): JSXNode[] | JSXNode | undefined {
return undefined;
}
if (isJSXNode(node)) {
if (node.type === Host || node.type === StaticChildren) {
if (node.type === Host || node.type === SkipRerender) {
return node;
} else if (typeof node.type === 'function') {
return processNode(node.type({ ...node.props, children: node.children }, node.key));
Expand Down

0 comments on commit 8028547

Please sign in to comment.