Skip to content

Commit d8fe6b3

Browse files
authored
fix: svg attributes are not set correctly
1 parent 16f1792 commit d8fe6b3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export { normalize } from './normalize';
22
export { serialize } from './serialize';
33
export { materialize, createComment, createElement, createTextNode } from './materialize';
44
export type { Visitor } from './materialize';
5-
export type { ParserNode, ParserAttribute, CommentNode, TextNode, ElementNode } from '@homebots/parse-html';
5+
export type { ParserNode, ParserAttribute, CommentNode, TextNode, ElementNode, PackedAttributes, PackedChildNode, PackedCommentNode, PackedDocumentNode, PackedElementNode, PackedTextNode } from '@homebots/parse-html';
6+
export { pack, unpack } from '@homebots/parse-html';

src/materialize.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { ParserNode, ParserAttribute, CommentNode, TextNode, ElementNode } from '@homebots/parse-html';
22

3-
const validAttribute = /^[a-z][a-z0-9-]+$/;
4-
const noop = () => {};
3+
const validAttribute = /^[a-zA-Z_][a-zA-Z0-9\-_:.]*$/;
54

65
export type Visitor = <T>(el: T, node: ParserNode) => T | null | undefined | void;
76

8-
export function materialize(node: ParserNode, visitor: Visitor = noop) {
7+
export function materialize(node: ParserNode, visitor: Visitor|null = null) {
98
let el: any;
109

1110
switch (node.type) {
@@ -33,7 +32,7 @@ export function materialize(node: ParserNode, visitor: Visitor = noop) {
3332
throw new Error(`Invalid node type: ${(node as any).type}`);
3433
}
3534

36-
return visitor(el, node) || el;
35+
return visitor && visitor(el, node) || el;
3736
}
3837

3938
export function createComment(node: CommentNode) {

0 commit comments

Comments
 (0)