|
|
|
|
@ -1,4 +1,13 @@
|
|
|
|
|
import { custom_event, append, append_hydration, insert, insert_hydration, detach, listen, attr } from './dom';
|
|
|
|
|
import {
|
|
|
|
|
custom_event,
|
|
|
|
|
append,
|
|
|
|
|
append_hydration,
|
|
|
|
|
insert,
|
|
|
|
|
insert_hydration,
|
|
|
|
|
detach,
|
|
|
|
|
listen,
|
|
|
|
|
attr
|
|
|
|
|
} from './dom';
|
|
|
|
|
import { SvelteComponent } from './Component';
|
|
|
|
|
import { is_void } from '../../shared/utils/names';
|
|
|
|
|
import { contenteditable_truthy_values } from './utils';
|
|
|
|
|
@ -7,7 +16,9 @@ import { contenteditable_truthy_values } from './utils';
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
export function dispatch_dev(type, detail) {
|
|
|
|
|
document.dispatchEvent(custom_event(type, { version: '__VERSION__', ...detail }, { bubbles: true }));
|
|
|
|
|
document.dispatchEvent(
|
|
|
|
|
custom_event(type, { version: '__VERSION__', ...detail }, { bubbles: true })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
/** @param {Node} target
|
|
|
|
|
* @param {Node} node
|
|
|
|
|
@ -84,14 +95,20 @@ export function detach_after_dev(before) {
|
|
|
|
|
* @param {boolean} has_stop_immediate_propagation
|
|
|
|
|
* @returns {() => void}
|
|
|
|
|
*/
|
|
|
|
|
export function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation, has_stop_immediate_propagation) {
|
|
|
|
|
const modifiers = options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : [];
|
|
|
|
|
if (has_prevent_default)
|
|
|
|
|
modifiers.push('preventDefault');
|
|
|
|
|
if (has_stop_propagation)
|
|
|
|
|
modifiers.push('stopPropagation');
|
|
|
|
|
if (has_stop_immediate_propagation)
|
|
|
|
|
modifiers.push('stopImmediatePropagation');
|
|
|
|
|
export function listen_dev(
|
|
|
|
|
node,
|
|
|
|
|
event,
|
|
|
|
|
handler,
|
|
|
|
|
options,
|
|
|
|
|
has_prevent_default,
|
|
|
|
|
has_stop_propagation,
|
|
|
|
|
has_stop_immediate_propagation
|
|
|
|
|
) {
|
|
|
|
|
const modifiers =
|
|
|
|
|
options === true ? ['capture'] : options ? Array.from(Object.keys(options)) : [];
|
|
|
|
|
if (has_prevent_default) modifiers.push('preventDefault');
|
|
|
|
|
if (has_stop_propagation) modifiers.push('stopPropagation');
|
|
|
|
|
if (has_stop_immediate_propagation) modifiers.push('stopImmediatePropagation');
|
|
|
|
|
dispatch_dev('SvelteDOMAddEventListener', { node, event, handler, modifiers });
|
|
|
|
|
const dispose = listen(node, event, handler, options);
|
|
|
|
|
return () => {
|
|
|
|
|
@ -106,10 +123,8 @@ export function listen_dev(node, event, handler, options, has_prevent_default, h
|
|
|
|
|
*/
|
|
|
|
|
export function attr_dev(node, attribute, value) {
|
|
|
|
|
attr(node, attribute, value);
|
|
|
|
|
if (value == null)
|
|
|
|
|
dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
|
|
|
|
|
else
|
|
|
|
|
dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
|
|
|
|
|
if (value == null) dispatch_dev('SvelteDOMRemoveAttribute', { node, attribute });
|
|
|
|
|
else dispatch_dev('SvelteDOMSetAttribute', { node, attribute, value });
|
|
|
|
|
}
|
|
|
|
|
/** @param {Element} node
|
|
|
|
|
* @param {string} property
|
|
|
|
|
@ -135,8 +150,7 @@ export function dataset_dev(node, property, value) {
|
|
|
|
|
*/
|
|
|
|
|
export function set_data_dev(text, data) {
|
|
|
|
|
data = '' + data;
|
|
|
|
|
if (text.data === data)
|
|
|
|
|
return;
|
|
|
|
|
if (text.data === data) return;
|
|
|
|
|
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
|
|
|
|
text.data = data;
|
|
|
|
|
}
|
|
|
|
|
@ -146,8 +160,7 @@ export function set_data_dev(text, data) {
|
|
|
|
|
*/
|
|
|
|
|
export function set_data_contenteditable_dev(text, data) {
|
|
|
|
|
data = '' + data;
|
|
|
|
|
if (text.wholeText === data)
|
|
|
|
|
return;
|
|
|
|
|
if (text.wholeText === data) return;
|
|
|
|
|
dispatch_dev('SvelteDOMSetData', { node: text, data });
|
|
|
|
|
text.data = data;
|
|
|
|
|
}
|
|
|
|
|
@ -159,8 +172,7 @@ export function set_data_contenteditable_dev(text, data) {
|
|
|
|
|
export function set_data_maybe_contenteditable_dev(text, data, attr_value) {
|
|
|
|
|
if (~contenteditable_truthy_values.indexOf(attr_value)) {
|
|
|
|
|
set_data_contenteditable_dev(text, data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
set_data_dev(text, data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -208,13 +220,11 @@ export function construct_svelte_component_dev(component, props) {
|
|
|
|
|
throw new Error(error_message);
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
} catch (err) {
|
|
|
|
|
const { message } = err;
|
|
|
|
|
if (typeof message === 'string' && message.indexOf('is not a constructor') !== -1) {
|
|
|
|
|
throw new Error(error_message);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -280,16 +290,15 @@ export class SvelteComponentDev extends SvelteComponent {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
/** @returns {void} */
|
|
|
|
|
$capture_state() { }
|
|
|
|
|
$capture_state() {}
|
|
|
|
|
/** @returns {void} */
|
|
|
|
|
$inject_state() { }
|
|
|
|
|
$inject_state() {}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated Use `SvelteComponent` instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512
|
|
|
|
|
* @extends SvelteComponentDev<Props, Events, Slots>
|
|
|
|
|
*/
|
|
|
|
|
export class SvelteComponentTyped extends SvelteComponentDev {
|
|
|
|
|
}
|
|
|
|
|
export class SvelteComponentTyped extends SvelteComponentDev {}
|
|
|
|
|
/** @returns {() => void} */
|
|
|
|
|
export function loop_guard(timeout) {
|
|
|
|
|
const start = Date.now();
|
|
|
|
|
@ -300,7 +309,6 @@ export function loop_guard(timeout) {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @typedef {Class<HTMLElement>} ComponentType
|
|
|
|
|
* @template {SvelteComponentDev} [Component=SvelteComponentDev]
|
|
|
|
|
|