Skip to content

Commit 2108417

Browse files
committed
why was that there
1 parent 5c33f35 commit 2108417

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/element.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
/** @import { Attribute, ClassDirective, DelegatedEvent, ExpressionMetadata, ExpressionTag, Namespace, OnDirective, RegularElement, StyleDirective, SvelteElement, SvelteNode } from '#compiler' */
33
/** @import { ComponentContext } from '../../types' */
44
import { ATTRIBUTE_ALIASES } from '../../../../../../constants.js';
5-
import { is_capture_event } from '../../../../../../utils.js';
5+
import { is_capture_event, is_passive_event } from '../../../../../../utils.js';
66
import { get_attribute_expression } from '../../../../../utils/ast.js';
77
import * as b from '../../../../../utils/builders.js';
8-
import { PassiveEvents } from '../../../../constants.js';
98
import { serialize_get_binding } from '../../utils.js';
109
import { serialize_event_handler, serialize_template_literal, serialize_update } from './utils.js';
1110

@@ -236,7 +235,7 @@ export function serialize_event(node, metadata, context) {
236235
} else if (node.modifiers.includes('nonpassive')) {
237236
args.push(b.literal(false));
238237
} else if (
239-
PassiveEvents.includes(node.name) &&
238+
is_passive_event(node.name) &&
240239
/** @type {OnDirective} */ (node).type !== 'OnDirective'
241240
) {
242241
// For on:something events we don't apply passive behaviour to match Svelte 4.

packages/svelte/src/compiler/phases/constants.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ export const DOMProperties = [
99
...DOM_BOOLEAN_ATTRIBUTES
1010
];
1111

12-
export const PassiveEvents = ['wheel', 'touchstart', 'touchmove', 'touchend', 'touchcancel'];
13-
1412
export const Runes = /** @type {const} */ ([
1513
'$state',
1614
'$state.frozen',

packages/svelte/src/internal/client/render.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { reset_head_anchor } from './dom/blocks/svelte-head.js';
2222
import * as w from './warnings.js';
2323
import * as e from './errors.js';
2424
import { assign_nodes } from './dom/template.js';
25-
import { PassiveEvents } from '../../compiler/phases/constants.js';
25+
import { is_passive_event } from '../../utils.js';
2626

2727
/**
2828
* This is normally true — block effects should run their intro transitions —
@@ -191,7 +191,7 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
191191
if (registered_events.has(event_name)) continue;
192192
registered_events.add(event_name);
193193

194-
var passive = PassiveEvents.includes(event_name);
194+
var passive = is_passive_event(event_name);
195195

196196
// Add the event listener to both the container and the document.
197197
// The container listener ensures we catch events from within in case

packages/svelte/src/utils.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,13 @@ export const DOM_BOOLEAN_ATTRIBUTES = [
179179
export function is_boolean_attribute(name) {
180180
return DOM_BOOLEAN_ATTRIBUTES.includes(name);
181181
}
182+
183+
const PASSIVE_EVENTS = ['wheel', 'touchstart', 'touchmove', 'touchend', 'touchcancel'];
184+
185+
/**
186+
* Returns `true` if `name` is a passive event
187+
* @param {string} name
188+
*/
189+
export function is_passive_event(name) {
190+
return PASSIVE_EVENTS.includes(name);
191+
}

0 commit comments

Comments
 (0)