@@ -7,9 +7,7 @@ const has_browser_globals = typeof window !== 'undefined';
7
7
// We cache the Node and Element prototype methods, so that subsequent calls-sites are monomorphic rather
8
8
// than megamorphic.
9
9
const node_prototype = /** @type {Node } */ ( has_browser_globals ? Node . prototype : { } ) ;
10
- const html_element_prototype = /** @type {Element } */ (
11
- has_browser_globals ? HTMLElement . prototype : { }
12
- ) ;
10
+ const element_prototype = /** @type {Element } */ ( has_browser_globals ? Element . prototype : { } ) ;
13
11
const text_prototype = /** @type {Text } */ ( has_browser_globals ? Text . prototype : { } ) ;
14
12
const map_prototype = Map . prototype ;
15
13
const append_child_method = node_prototype . appendChild ;
@@ -18,11 +16,11 @@ const map_set_method = map_prototype.set;
18
16
const map_get_method = map_prototype . get ;
19
17
const map_delete_method = map_prototype . delete ;
20
18
// @ts -expect-error improve perf of expando on DOM events
21
- html_element_prototype . __click = undefined ;
19
+ element_prototype . __click = undefined ;
22
20
// @ts -expect-error improve perf of expando on DOM text updates
23
21
text_prototype . __nodeValue = ' ' ;
24
22
// @ts -expect-error improve perf of expando on DOM className updates
25
- html_element_prototype . __className = '' ;
23
+ element_prototype . __className = '' ;
26
24
27
25
const first_child_get = /** @type {(this: Node) => ChildNode | null } */ (
28
26
// @ts -ignore
@@ -39,6 +37,11 @@ const text_content_set = /** @type {(this: Node, text: string ) => void} */ (
39
37
has_browser_globals ? get_descriptor ( node_prototype , 'textContent' ) . set : null
40
38
) ;
41
39
40
+ const class_name_set = /** @type {(this: Element, class_name: string) => void } */ (
41
+ // @ts -ignore
42
+ has_browser_globals ? get_descriptor ( element_prototype , 'className' ) . set : null
43
+ ) ;
44
+
42
45
/**
43
46
* @template {Element} E
44
47
* @template {Node} T
@@ -144,6 +147,16 @@ export function sibling(node) {
144
147
return next_sibling ;
145
148
}
146
149
150
+ /**
151
+ * @template {Element} N
152
+ * @param {N } node
153
+ * @param {string } class_name
154
+ * @returns {void }
155
+ */
156
+ export function set_class_name ( node , class_name ) {
157
+ class_name_set . call ( node , class_name ) ;
158
+ }
159
+
147
160
/**
148
161
* @template {Node} N
149
162
* @param {N } node
0 commit comments