From caab8dad052eff0d26deeaea478229e4c572ede9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 23 May 2024 22:41:38 -0400 Subject: [PATCH] chore: remove unused code (#11762) * chore: remove unused code * remove text_prototype * more --- .../src/internal/client/dom/operations.js | 34 +++++-------------- packages/svelte/src/internal/client/render.js | 3 -- 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/operations.js b/packages/svelte/src/internal/client/dom/operations.js index 02d150ba3f..508ea47388 100644 --- a/packages/svelte/src/internal/client/dom/operations.js +++ b/packages/svelte/src/internal/client/dom/operations.js @@ -3,26 +3,11 @@ import { DEV } from 'esm-env'; import { init_array_prototype_warnings } from '../dev/equality.js'; import { current_effect } from '../runtime.js'; -// We cache the Node and Element prototype methods, so that we can avoid doing -// expensive prototype chain lookups. - -/** @type {Node} */ -var node_prototype; - -/** @type {Element} */ -var element_prototype; - -/** @type {Text} */ -var text_prototype; - // export these for reference in the compiled code, making global name deduplication unnecessary -/** - * @type {Window} - */ +/** @type {Window} */ export var $window; -/** - * @type {Document} - */ + +/** @type {Document} */ export var $document; /** @@ -30,29 +15,28 @@ export var $document; * where these globals are not available while avoiding a separate server entry point */ export function init_operations() { - if (node_prototype !== undefined) { + if ($window !== undefined) { return; } - node_prototype = Node.prototype; - element_prototype = Element.prototype; - text_prototype = Text.prototype; - $window = window; $document = document; + var element_prototype = Element.prototype; + // the following assignments improve perf of lookups on DOM nodes // @ts-expect-error element_prototype.__click = undefined; // @ts-expect-error - text_prototype.__nodeValue = ' '; - // @ts-expect-error element_prototype.__className = ''; // @ts-expect-error element_prototype.__attributes = null; // @ts-expect-error element_prototype.__e = undefined; + // @ts-expect-error + Text.prototype.__nodeValue = ' '; + if (DEV) { // @ts-expect-error element_prototype.__svelte_meta = null; diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index a900abbb06..101ba6f1af 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -131,8 +131,6 @@ export function hydrate(component, options) { const target = options.target; const previous_hydrate_nodes = hydrate_nodes; - let hydrated = false; - try { // Don't flush previous effects to ensure order of outer effects stays consistent return flush_sync(() => { @@ -156,7 +154,6 @@ export function hydrate(component, options) { // flush_sync will run this callback and then synchronously run any pending effects, // which don't belong to the hydration phase anymore - therefore reset it here set_hydrating(false); - hydrated = true; return instance; }, false);