|
2 | 2 | import { hydrate_node, hydrating, set_hydrate_node } from './hydration.js';
|
3 | 3 | import { DEV } from 'esm-env';
|
4 | 4 | import { init_array_prototype_warnings } from '../dev/equality.js';
|
5 |
| -import { get_descriptor } from '../../shared/utils.js'; |
| 5 | +import { get_descriptor, is_extensible } from '../../shared/utils.js'; |
6 | 6 |
|
7 | 7 | // export these for reference in the compiled code, making global name deduplication unnecessary
|
8 | 8 | /** @type {Window} */
|
@@ -34,26 +34,31 @@ export function init_operations() {
|
34 | 34 |
|
35 | 35 | var element_prototype = Element.prototype;
|
36 | 36 | var node_prototype = Node.prototype;
|
| 37 | + var text_prototype = Text.prototype; |
37 | 38 |
|
38 | 39 | // @ts-ignore
|
39 | 40 | first_child_getter = get_descriptor(node_prototype, 'firstChild').get;
|
40 | 41 | // @ts-ignore
|
41 | 42 | next_sibling_getter = get_descriptor(node_prototype, 'nextSibling').get;
|
42 | 43 |
|
43 |
| - // the following assignments improve perf of lookups on DOM nodes |
44 |
| - // @ts-expect-error |
45 |
| - element_prototype.__click = undefined; |
46 |
| - // @ts-expect-error |
47 |
| - element_prototype.__className = undefined; |
48 |
| - // @ts-expect-error |
49 |
| - element_prototype.__attributes = null; |
50 |
| - // @ts-expect-error |
51 |
| - element_prototype.__style = undefined; |
52 |
| - // @ts-expect-error |
53 |
| - element_prototype.__e = undefined; |
54 |
| - |
55 |
| - // @ts-expect-error |
56 |
| - Text.prototype.__t = undefined; |
| 44 | + if (is_extensible(element_prototype)) { |
| 45 | + // the following assignments improve perf of lookups on DOM nodes |
| 46 | + // @ts-expect-error |
| 47 | + element_prototype.__click = undefined; |
| 48 | + // @ts-expect-error |
| 49 | + element_prototype.__className = undefined; |
| 50 | + // @ts-expect-error |
| 51 | + element_prototype.__attributes = null; |
| 52 | + // @ts-expect-error |
| 53 | + element_prototype.__style = undefined; |
| 54 | + // @ts-expect-error |
| 55 | + element_prototype.__e = undefined; |
| 56 | + } |
| 57 | + |
| 58 | + if (is_extensible(text_prototype)) { |
| 59 | + // @ts-expect-error |
| 60 | + text_prototype.__t = undefined; |
| 61 | + } |
57 | 62 |
|
58 | 63 | if (DEV) {
|
59 | 64 | // @ts-expect-error
|
|
0 commit comments