Skip to content

Commit

Permalink
improve some internals
Browse files Browse the repository at this point in the history
  • Loading branch information
huang2002 committed Jan 22, 2019
1 parent af0b22f commit 0b17fc6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/core/HNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store, createStore, HandlerMap, PartialHandlers } from "./Store";
import { _document, _isArray, _Infinity, _Map, _entries } from "../utils/refCache";
import { _document, _isArray, _Infinity, _Map, _entries, _createTextNode } from "../utils/refCache";
import { toArr, isHNode } from "../utils/helpers";
import { handleProp } from "./handleProp";
import { handleError } from "./handleError";
Expand Down Expand Up @@ -54,9 +54,9 @@ export const toNodeArr = function toNodes(
const srcType = typeof src;

if (srcType === 'string') {
return [_document.createTextNode(src as string)];
return [_createTextNode(src as string)];
} else if (srcType === 'number') {
return [_document.createTextNode(String(src))];
return [_createTextNode(String(src))];
}

if (src) {
Expand Down Expand Up @@ -135,6 +135,6 @@ export const toNodeArr = function toNodes(

}

return [_document.createTextNode('')];
return [_createTextNode('')];

};
1 change: 0 additions & 1 deletion src/ext/Fragment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { define } from "../core/registry";
import { _document, _Symbol } from "../utils/refCache";

export interface FragmentProps {
children: unknown;
Expand Down
2 changes: 1 addition & 1 deletion src/ext/Portal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { renderToDOM } from "../core/render";
import { define } from "../core/registry";
import { _document, _Symbol, _null } from "../utils/refCache";
import { _document, _null } from "../utils/refCache";
import { clear } from "../utils/clear";
import { HNode } from "../core/HNode";
import { FragmentProps } from "./Fragment";
Expand Down
1 change: 1 addition & 0 deletions src/utils/refCache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const _document = document,
_createTextNode = _document.createTextNode.bind(_document),
_Object = Object,
_Array = Array,
_String = String,
Expand Down

0 comments on commit 0b17fc6

Please sign in to comment.