Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose isSerializationFirstNode and SERIALIZATION_FIRST_NODE_STRING #788

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/@glimmer/runtime/lib/vm/rehydrate-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Environment } from '../environment';
import Bounds, { bounds, Cursor } from '../bounds';
import { Simple, Option, Opaque } from "@glimmer/interfaces";
import { DynamicContentWrapper } from './content/dynamic';
import { expect, assert, Stack } from "@glimmer/util";
import { expect, assert, Stack, isSerializationFirstNode, SERIALIZATION_FIRST_NODE_STRING} from "@glimmer/util";
import { SVG_NAMESPACE } from '../dom/helper';

export class RehydratingCursor extends Cursor {
Expand All @@ -31,11 +31,11 @@ export class RehydrateBuilder extends NewElementBuilder implements ElementBuilde
let node = this.currentCursor!.element.firstChild;

while (node !== null) {
if (isComment(node) && node.nodeValue === '%+b:0%') { break; }
if (isComment(node) && isSerializationFirstNode(node)) { break; }
node = node.nextSibling;
}

assert(node, 'Must have opening comment <!--%+b:0%--> for rehydration.');
assert(node, `Must have opening comment <!--${SERIALIZATION_FIRST_NODE_STRING}--> for rehydration.`);
this.candidate = node;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/@glimmer/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export { default as assert } from './lib/assert';
export { assign, fillNulls } from './lib/object-utils';
export { ensureGuid, initializeGuid, HasGuid } from './lib/guid';

export { isSerializationFirstNode, SERIALIZATION_FIRST_NODE_STRING } from './lib/is-serialization-first-node';

export { Stack, Dict, Set, DictSet, dict } from './lib/collections';
export { EMPTY_SLICE, LinkedList, LinkedListNode, ListNode, CloneableListNode, ListSlice, Slice } from './lib/list-utils';
export { EMPTY_ARRAY } from './lib/array-utils';
Expand Down
7 changes: 7 additions & 0 deletions packages/@glimmer/util/lib/is-serialization-first-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Simple } from '@glimmer/interfaces';

export const SERIALIZATION_FIRST_NODE_STRING = '%+b:0%';

export function isSerializationFirstNode(node: Simple.Node): boolean {
return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING;
};