MCPcopy
hub / github.com/sveltejs/svelte / init_operations

Function init_operations

packages/svelte/src/internal/client/dom/operations.js:38–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36 * where these globals are not available while avoiding a separate server entry point
37 */
38export function init_operations() {
39 if ($window !== undefined) {
40 return;
41 }
42
43 $window = window;
44 $document = document;
45 is_firefox = /Firefox/.test(navigator.userAgent);
46
47 var element_prototype = Element.prototype;
48 var node_prototype = Node.prototype;
49 var text_prototype = Text.prototype;
50
51 // @ts-ignore
52 first_child_getter = get_descriptor(node_prototype, 'firstChild').get;
53 // @ts-ignore
54 next_sibling_getter = get_descriptor(node_prototype, 'nextSibling').get;
55
56 if (is_extensible(element_prototype)) {
57 // the following assignments improve perf of lookups on DOM nodes
58 /** @type {any} */ (element_prototype)[CLASS_CACHE] = undefined;
59 /** @type {any} */ (element_prototype)[ATTRIBUTES_CACHE] = null;
60 /** @type {any} */ (element_prototype)[STYLE_CACHE] = undefined;
61 // @ts-expect-error
62 element_prototype.__e = undefined;
63 }
64
65 if (is_extensible(text_prototype)) {
66 /** @type {any} */ (text_prototype)[TEXT_CACHE] = undefined;
67 }
68
69 if (DEV) {
70 // @ts-expect-error
71 element_prototype.__svelte_meta = null;
72
73 init_array_prototype_warnings();
74 }
75}
76
77/**
78 * @param {string} value

Callers 2

hydrateFunction · 0.90
_mountFunction · 0.90

Calls 1

Tested by

no test coverage detected