Skip to content

Commit

Permalink
解决循环引用
Browse files Browse the repository at this point in the history
  • Loading branch information
big-camel committed Apr 13, 2022
1 parent a92a137 commit d8526b0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
10 changes: 1 addition & 9 deletions packages/engine/src/node/entry.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
DATA_ELEMENT,
ROOT,
ROOT_SELECTOR,
EDITABLE,
EDITABLE_SELECTOR,
} from '../constants/root';
import { CARD_EDITABLE_KEY, CARD_TAG, CARD_TYPE_KEY } from '../constants/card';
import { ANCHOR, CURSOR, FOCUS } from '../constants/selection';
import { ROOT_SELECTOR, EDITABLE_SELECTOR } from '../constants/root';
import DOMEvent from './event';
import $ from './parse';
import {
Expand Down
10 changes: 3 additions & 7 deletions packages/engine/src/node/utils.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { getDocument } from '../utils/node';
import { ElementInterface, NodeInterface, Selector } from '../types';
import {
ANCHOR,
CARD_EDITABLE_KEY,
CARD_TAG,
CARD_TYPE_KEY,
CURSOR,
DATA_ELEMENT,
EDITABLE,
EDITABLE_SELECTOR,
FOCUS,
ROOT,
ROOT_SELECTOR,
} from '../constants';
} from '../constants/root';
import { CARD_EDITABLE_KEY, CARD_TAG, CARD_TYPE_KEY } from '../constants/card';
import { ANCHOR, CURSOR, FOCUS } from '../constants/selection';

export const isNodeEntry = (selector: Selector): selector is NodeInterface => {
return !!selector && (selector as NodeInterface).get !== undefined;
Expand Down
3 changes: 1 addition & 2 deletions packages/engine/src/utils/node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isNodeEntry } from '../node/utils';
import { DATA_ELEMENT, ROOT } from '../constants/root';
import { NodeInterface } from '../types/node';

Expand All @@ -21,7 +20,7 @@ export const getDocument = (node?: Node): Document => {
* @param node 节点
*/
export const combinText = (node: NodeInterface | Node) => {
if (isNodeEntry(node)) node = node[0];
if (!(node instanceof Node)) node = node[0];
node.normalize();
};

Expand Down

0 comments on commit d8526b0

Please sign in to comment.