Socket
Socket
Sign inDemoInstall

svelte

Package Overview
Dependencies
Maintainers
3
Versions
738
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte - npm Package Compare versions

Comparing version 5.0.0-next.137 to 5.0.0-next.138

2

package.json

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "5.0.0-next.137",
"version": "5.0.0-next.138",
"type": "module",

@@ -8,0 +8,0 @@ "types": "./types/index.d.ts",

@@ -142,3 +142,3 @@ import * as e from '../../../errors.js';

parser.allow_whitespace();
allow_comment_or_whitespace(parser);

@@ -328,3 +328,3 @@ if (inside_pseudo_class ? parser.match(')') : parser.match('{')) {

const index = parser.index;
parser.allow_whitespace();
allow_comment_or_whitespace(parser);

@@ -331,0 +331,0 @@ if (parser.match(',') || (inside_pseudo_class ? parser.match(')') : parser.match('{'))) {

@@ -241,3 +241,3 @@ import MagicString from 'magic-string';

if (relative_selector.selectors.every((s) => s.type === 'NestingSelector')) {
if (relative_selector.selectors.some((s) => s.type === 'NestingSelector')) {
continue;

@@ -244,0 +244,0 @@ }

@@ -6,6 +6,7 @@ import { DEV } from 'esm-env';

import { create_event, delegate } from './events.js';
import { autofocus } from './misc.js';
import { add_form_reset_listener, autofocus } from './misc.js';
import { effect, effect_root } from '../../reactivity/effects.js';
import * as w from '../../warnings.js';
import { LOADING_ATTR_SYMBOL } from '../../constants.js';
import { queue_idle_task } from '../task.js';

@@ -15,3 +16,3 @@ /**

* to remove it upon hydration to avoid a bug when someone resets the form value.
* @param {HTMLInputElement | HTMLSelectElement} dom
* @param {HTMLInputElement} dom
* @returns {void}

@@ -21,8 +22,19 @@ */

if (hydrating) {
// using getAttribute instead of dom.value allows us to have
// null instead of "on" if the user didn't set a value
const value = dom.getAttribute('value');
set_attribute(dom, 'value', null);
set_attribute(dom, 'checked', null);
if (value) dom.value = value;
let already_removed = false;
// We try and remove the default attributes later, rather than sync during hydration.
// Doing it sync during hydration has a negative impact on performance, but deferring the
// work in an idle task alleviates this greatly. If a form reset event comes in before
// the idle callback, then we ensure the input defaults are cleared just before.
const remove_defaults = () => {
if (already_removed) return;
already_removed = true;
const value = dom.getAttribute('value');
set_attribute(dom, 'value', null);
set_attribute(dom, 'checked', null);
if (value) dom.value = value;
};
// @ts-expect-error
dom.__on_r = remove_defaults;
queue_idle_task(remove_defaults);
add_form_reset_listener();
}

@@ -33,2 +45,28 @@ }

* @param {Element} element
* @param {any} value
*/
export function set_value(element, value) {
// @ts-expect-error
var attributes = (element.__attributes ??= {});
if (attributes.value === (attributes.value = value)) return;
// @ts-expect-error
element.value = value;
}
/**
* @param {Element} element
* @param {boolean} checked
*/
export function set_checked(element, checked) {
// @ts-expect-error
var attributes = (element.__attributes ??= {});
if (attributes.checked === (attributes.checked = checked)) return;
// @ts-expect-error
element.checked = checked;
}
/**
* @param {Element} element
* @param {string} attribute

@@ -35,0 +73,0 @@ * @param {string | null} value

import { render_effect } from '../../../reactivity/effects.js';
import { add_form_reset_listener } from '../misc.js';

@@ -29,4 +30,2 @@ /**

let listening_to_form_reset = false;
/**

@@ -56,22 +55,3 @@ * Listen to the given event, and then instantiate a global form reset listener if not already done,

if (!listening_to_form_reset) {
listening_to_form_reset = true;
document.addEventListener(
'reset',
(evt) => {
// Needs to happen one tick later or else the dom properties of the form
// elements have not updated to their reset values yet
Promise.resolve().then(() => {
if (!evt.defaultPrevented) {
for (const e of /**@type {HTMLFormElement} */ (evt.target).elements) {
// @ts-expect-error
e.__on_r?.();
}
}
});
},
// In the capture phase to guarantee we get noticed of it (no possiblity of stopPropagation)
{ capture: true }
);
}
add_form_reset_listener();
}
import { STATE_SYMBOL } from '../../../constants.js';
import { effect, render_effect } from '../../../reactivity/effects.js';
import { untrack } from '../../../runtime.js';
import { queue_task } from '../../task.js';
import { queue_micro_task } from '../../task.js';

@@ -52,3 +52,3 @@ /**

// We cannot use effects in the teardown phase, we we use a microtask instead.
queue_task(() => {
queue_micro_task(() => {
if (parts && is_bound_this(get_value(...parts), element_or_component)) {

@@ -55,0 +55,0 @@ update(null, ...parts);

@@ -5,3 +5,3 @@ import { render_effect } from '../../reactivity/effects.js';

import { hydrating } from '../hydration.js';
import { queue_task } from '../task.js';
import { queue_micro_task } from '../task.js';

@@ -60,3 +60,3 @@ /**

if (event_name.startsWith('pointer')) {
queue_task(() => {
queue_micro_task(() => {
dom.addEventListener(event_name, target_handler, options);

@@ -63,0 +63,0 @@ });

@@ -34,1 +34,26 @@ import { hydrating } from '../hydration.js';

}
let listening_to_form_reset = false;
export function add_form_reset_listener() {
if (!listening_to_form_reset) {
listening_to_form_reset = true;
document.addEventListener(
'reset',
(evt) => {
// Needs to happen one tick later or else the dom properties of the form
// elements have not updated to their reset values yet
Promise.resolve().then(() => {
if (!evt.defaultPrevented) {
for (const e of /**@type {HTMLFormElement} */ (evt.target).elements) {
// @ts-expect-error
e.__on_r?.();
}
}
});
},
// In the capture phase to guarantee we get noticed of it (no possiblity of stopPropagation)
{ capture: true }
);
}
}
import { run_all } from '../../shared/utils.js';
let is_task_queued = false;
// Fallback for when requestIdleCallback is not available
const request_idle_callback =
typeof requestIdleCallback === 'undefined'
? (/** @type {() => void} */ cb) => setTimeout(cb, 1)
: requestIdleCallback;
let is_micro_task_queued = false;
let is_idle_task_queued = false;
/** @type {Array<() => void>} */
let current_queued_tasks = [];
let current_queued_miro_tasks = [];
/** @type {Array<() => void>} */
let current_queued_idle_tasks = [];
function process_task() {
is_task_queued = false;
const tasks = current_queued_tasks.slice();
current_queued_tasks = [];
function process_micro_tasks() {
is_micro_task_queued = false;
const tasks = current_queued_miro_tasks.slice();
current_queued_miro_tasks = [];
run_all(tasks);
}
function process_idle_tasks() {
is_idle_task_queued = false;
const tasks = current_queued_idle_tasks.slice();
current_queued_idle_tasks = [];
run_all(tasks);
}
/**
* @param {() => void} fn
*/
export function queue_task(fn) {
if (!is_task_queued) {
is_task_queued = true;
queueMicrotask(process_task);
export function queue_micro_task(fn) {
if (!is_micro_task_queued) {
is_micro_task_queued = true;
queueMicrotask(process_micro_tasks);
}
current_queued_tasks.push(fn);
current_queued_miro_tasks.push(fn);
}
/**
* @param {() => void} fn
*/
export function queue_idle_task(fn) {
if (!is_idle_task_queued) {
is_idle_task_queued = true;
request_idle_callback(process_idle_tasks);
}
current_queued_idle_tasks.push(fn);
}
/**
* Synchronously run any queued tasks.
*/
export function flush_tasks() {
if (is_task_queued) {
process_task();
if (is_micro_task_queued) {
process_micro_tasks();
}
if (is_idle_task_queued) {
process_idle_tasks();
}
}

@@ -30,3 +30,5 @@ export { add_locations } from './dev/elements.js';

set_xlink_attribute,
handle_lazy_img
handle_lazy_img,
set_value,
set_checked
} from './dom/elements/attributes.js';

@@ -33,0 +35,0 @@ export { set_class, set_svg_class, set_mathml_class, toggle_class } from './dom/elements/class.js';

@@ -423,4 +423,4 @@ import { DEV } from 'esm-env';

if (reactions_length === 0 && (dependency.f & UNOWNED) !== 0) {
// If the signal is unowned then we need to make sure to change it to dirty.
set_signal_status(dependency, DIRTY);
// If the signal is unowned then we need to make sure to change it to maybe dirty.
set_signal_status(dependency, MAYBE_DIRTY);
remove_reactions(/** @type {import('#client').Derived} **/ (dependency), 0);

@@ -427,0 +427,0 @@ }

@@ -9,3 +9,3 @@ // generated during release, do not modify

*/
export const VERSION = '5.0.0-next.137';
export const VERSION = '5.0.0-next.138';
export const PUBLIC_VERSION = '5';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc