svelte 3.44.3 → 3.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/LICENSE.md +1 -1
- package/compiler.js +178 -25
- package/compiler.js.map +1 -1
- package/compiler.mjs +178 -25
- package/compiler.mjs.map +1 -1
- package/internal/index.js +2 -2
- package/internal/index.mjs +2 -2
- package/package.json +4 -4
- package/types/compiler/compile/nodes/shared/Context.d.ts +10 -1
- package/types/compiler/compile/render_dom/wrappers/Element/Binding.d.ts +1 -0
- package/types/compiler/utils/namespaces.d.ts +1 -1
package/compiler.mjs
CHANGED
|
@@ -6993,7 +6993,10 @@ const handlers = {
|
|
|
6993
6993
|
|
|
6994
6994
|
chunks.push(c(' => '));
|
|
6995
6995
|
|
|
6996
|
-
if (
|
|
6996
|
+
if (
|
|
6997
|
+
node.body.type === 'ObjectExpression' ||
|
|
6998
|
+
(node.body.type === 'AssignmentExpression' && node.body.left.type === 'ObjectPattern')
|
|
6999
|
+
) {
|
|
6997
7000
|
chunks.push(
|
|
6998
7001
|
c('('),
|
|
6999
7002
|
...handle(node.body, state),
|
|
@@ -19217,7 +19220,7 @@ function fix_attribute_casing(name) {
|
|
|
19217
19220
|
|
|
19218
19221
|
// The `foreign` namespace covers all DOM implementations that aren't HTML5.
|
|
19219
19222
|
// It opts out of HTML5-specific a11y checks and case-insensitive attribute names.
|
|
19220
|
-
const foreign = 'https://svelte.dev/docs#
|
|
19223
|
+
const foreign = 'https://svelte.dev/docs#template-syntax-svelte-options';
|
|
19221
19224
|
const html = 'http://www.w3.org/1999/xhtml';
|
|
19222
19225
|
const mathml = 'http://www.w3.org/1998/Math/MathML';
|
|
19223
19226
|
const svg = 'http://www.w3.org/2000/svg';
|
|
@@ -19849,6 +19852,28 @@ class BindingWrapper {
|
|
|
19849
19852
|
});
|
|
19850
19853
|
return dependencies;
|
|
19851
19854
|
}
|
|
19855
|
+
get_update_dependencies() {
|
|
19856
|
+
const object = this.object;
|
|
19857
|
+
const dependencies = new Set();
|
|
19858
|
+
if (this.node.expression.template_scope.names.has(object)) {
|
|
19859
|
+
this.node.expression.template_scope.dependencies_for_name
|
|
19860
|
+
.get(object)
|
|
19861
|
+
.forEach((name) => dependencies.add(name));
|
|
19862
|
+
}
|
|
19863
|
+
else {
|
|
19864
|
+
dependencies.add(object);
|
|
19865
|
+
}
|
|
19866
|
+
const result = new Set(dependencies);
|
|
19867
|
+
dependencies.forEach((dependency) => {
|
|
19868
|
+
const indirect_dependencies = this.parent.renderer.component.indirect_dependencies.get(dependency);
|
|
19869
|
+
if (indirect_dependencies) {
|
|
19870
|
+
indirect_dependencies.forEach(indirect_dependency => {
|
|
19871
|
+
result.add(indirect_dependency);
|
|
19872
|
+
});
|
|
19873
|
+
}
|
|
19874
|
+
});
|
|
19875
|
+
return result;
|
|
19876
|
+
}
|
|
19852
19877
|
is_readonly_media_attribute() {
|
|
19853
19878
|
return this.node.is_readonly_media_attribute();
|
|
19854
19879
|
}
|
|
@@ -20140,7 +20165,7 @@ function bind_this(component, block, binding, variable) {
|
|
|
20140
20165
|
block.renderer.add_to_context(fn.name);
|
|
20141
20166
|
const callee = block.renderer.reference(fn.name);
|
|
20142
20167
|
const { contextual_dependencies, mutation } = binding.handler;
|
|
20143
|
-
const dependencies = binding.
|
|
20168
|
+
const dependencies = binding.get_update_dependencies();
|
|
20144
20169
|
const body = b `
|
|
20145
20170
|
${mutation}
|
|
20146
20171
|
${Array.from(dependencies)
|
|
@@ -21452,7 +21477,7 @@ class ElementWrapper extends Wrapper {
|
|
|
21452
21477
|
const contextual_dependencies = new Set();
|
|
21453
21478
|
binding_group.bindings.forEach(binding => {
|
|
21454
21479
|
// TODO this is a mess
|
|
21455
|
-
add_to_set(dependencies, binding.
|
|
21480
|
+
add_to_set(dependencies, binding.get_update_dependencies());
|
|
21456
21481
|
add_to_set(contextual_dependencies, binding.handler.contextual_dependencies);
|
|
21457
21482
|
binding.render(block, lock);
|
|
21458
21483
|
});
|
|
@@ -22057,12 +22082,13 @@ class IfBlockWrapper extends Wrapper {
|
|
|
22057
22082
|
if (this.needs_update) {
|
|
22058
22083
|
block.chunks.init.push(b `
|
|
22059
22084
|
function ${select_block_type}(#ctx, #dirty) {
|
|
22060
|
-
${this.branches.map(({ dependencies, condition, snippet
|
|
22085
|
+
${this.branches.map(({ dependencies, condition, snippet }) => {
|
|
22086
|
+
return b `${snippet && dependencies.length > 0 ? b `if (${block.renderer.dirty(dependencies)}) ${condition} = null;` : null}`;
|
|
22087
|
+
})}
|
|
22088
|
+
${this.branches.map(({ condition, snippet, block }) => condition
|
|
22061
22089
|
? b `
|
|
22062
|
-
|
|
22063
|
-
|
|
22064
|
-
: b `if (${condition} == null) ${condition} = !!${snippet}`)}
|
|
22065
|
-
if (${condition}) return ${block.name};`
|
|
22090
|
+
${snippet && b `if (${condition} == null) ${condition} = !!${snippet}`}
|
|
22091
|
+
if (${condition}) return ${block.name};`
|
|
22066
22092
|
: b `return ${block.name};`)}
|
|
22067
22093
|
}
|
|
22068
22094
|
`);
|
|
@@ -22160,11 +22186,12 @@ class IfBlockWrapper extends Wrapper {
|
|
|
22160
22186
|
${this.needs_update
|
|
22161
22187
|
? b `
|
|
22162
22188
|
function ${select_block_type}(#ctx, #dirty) {
|
|
22163
|
-
${this.branches.map(({ dependencies, condition, snippet }
|
|
22189
|
+
${this.branches.map(({ dependencies, condition, snippet }) => {
|
|
22190
|
+
return b `${snippet && dependencies.length > 0 ? b `if (${block.renderer.dirty(dependencies)}) ${condition} = null;` : null}`;
|
|
22191
|
+
})}
|
|
22192
|
+
${this.branches.map(({ condition, snippet }, i) => condition
|
|
22164
22193
|
? b `
|
|
22165
|
-
${snippet && (
|
|
22166
|
-
? b `if (${condition} == null || ${block.renderer.dirty(dependencies)}) ${condition} = !!${snippet}`
|
|
22167
|
-
: b `if (${condition} == null) ${condition} = !!${snippet}`)}
|
|
22194
|
+
${snippet && b `if (${condition} == null) ${condition} = !!${snippet}`}
|
|
22168
22195
|
if (${condition}) return ${i};`
|
|
22169
22196
|
: b `return ${i};`)}
|
|
22170
22197
|
${!has_else && b `return -1;`}
|
|
@@ -22638,6 +22665,10 @@ var compiler_warnings = {
|
|
|
22638
22665
|
code: 'a11y-unknown-role',
|
|
22639
22666
|
message: `A11y: Unknown role '${role}'` + (suggestion ? ` (did you mean '${suggestion}'?)` : '')
|
|
22640
22667
|
}),
|
|
22668
|
+
a11y_no_redundant_roles: (role) => ({
|
|
22669
|
+
code: 'a11y-no-redundant-roles',
|
|
22670
|
+
message: `A11y: Redundant role '${role}'`
|
|
22671
|
+
}),
|
|
22641
22672
|
a11y_accesskey: {
|
|
22642
22673
|
code: 'a11y-accesskey',
|
|
22643
22674
|
message: 'A11y: Avoid using accesskey'
|
|
@@ -25971,7 +26002,7 @@ class CatchBlock extends AbstractBlock {
|
|
|
25971
26002
|
}
|
|
25972
26003
|
}
|
|
25973
26004
|
|
|
25974
|
-
function unpack_destructuring(contexts, node, modifier = node => node, default_modifier = node => node) {
|
|
26005
|
+
function unpack_destructuring({ contexts, node, modifier = (node) => node, default_modifier = (node) => node, scope, component }) {
|
|
25975
26006
|
if (!node)
|
|
25976
26007
|
return;
|
|
25977
26008
|
if (node.type === 'Identifier') {
|
|
@@ -25991,14 +26022,36 @@ function unpack_destructuring(contexts, node, modifier = node => node, default_m
|
|
|
25991
26022
|
else if (node.type === 'ArrayPattern') {
|
|
25992
26023
|
node.elements.forEach((element, i) => {
|
|
25993
26024
|
if (element && element.type === 'RestElement') {
|
|
25994
|
-
unpack_destructuring(
|
|
26025
|
+
unpack_destructuring({
|
|
26026
|
+
contexts,
|
|
26027
|
+
node: element,
|
|
26028
|
+
modifier: (node) => x `${modifier(node)}.slice(${i})`,
|
|
26029
|
+
default_modifier,
|
|
26030
|
+
scope,
|
|
26031
|
+
component
|
|
26032
|
+
});
|
|
25995
26033
|
}
|
|
25996
26034
|
else if (element && element.type === 'AssignmentPattern') {
|
|
25997
26035
|
const n = contexts.length;
|
|
25998
|
-
|
|
26036
|
+
mark_referenced(element.right, scope, component);
|
|
26037
|
+
unpack_destructuring({
|
|
26038
|
+
contexts,
|
|
26039
|
+
node: element.left,
|
|
26040
|
+
modifier: (node) => x `${modifier(node)}[${i}]`,
|
|
26041
|
+
default_modifier: (node, to_ctx) => x `${node} !== undefined ? ${node} : ${update_reference(contexts, n, element.right, to_ctx)}`,
|
|
26042
|
+
scope,
|
|
26043
|
+
component
|
|
26044
|
+
});
|
|
25999
26045
|
}
|
|
26000
26046
|
else {
|
|
26001
|
-
unpack_destructuring(
|
|
26047
|
+
unpack_destructuring({
|
|
26048
|
+
contexts,
|
|
26049
|
+
node: element,
|
|
26050
|
+
modifier: (node) => x `${modifier(node)}[${i}]`,
|
|
26051
|
+
default_modifier,
|
|
26052
|
+
scope,
|
|
26053
|
+
component
|
|
26054
|
+
});
|
|
26002
26055
|
}
|
|
26003
26056
|
});
|
|
26004
26057
|
}
|
|
@@ -26006,7 +26059,14 @@ function unpack_destructuring(contexts, node, modifier = node => node, default_m
|
|
|
26006
26059
|
const used_properties = [];
|
|
26007
26060
|
node.properties.forEach((property) => {
|
|
26008
26061
|
if (property.type === 'RestElement') {
|
|
26009
|
-
unpack_destructuring(
|
|
26062
|
+
unpack_destructuring({
|
|
26063
|
+
contexts,
|
|
26064
|
+
node: property.argument,
|
|
26065
|
+
modifier: (node) => x `@object_without_properties(${modifier(node)}, [${used_properties}])`,
|
|
26066
|
+
default_modifier,
|
|
26067
|
+
scope,
|
|
26068
|
+
component
|
|
26069
|
+
});
|
|
26010
26070
|
}
|
|
26011
26071
|
else {
|
|
26012
26072
|
const key = property.key;
|
|
@@ -26014,10 +26074,25 @@ function unpack_destructuring(contexts, node, modifier = node => node, default_m
|
|
|
26014
26074
|
used_properties.push(x `"${key.name}"`);
|
|
26015
26075
|
if (value.type === 'AssignmentPattern') {
|
|
26016
26076
|
const n = contexts.length;
|
|
26017
|
-
|
|
26077
|
+
mark_referenced(value.right, scope, component);
|
|
26078
|
+
unpack_destructuring({
|
|
26079
|
+
contexts,
|
|
26080
|
+
node: value.left,
|
|
26081
|
+
modifier: (node) => x `${modifier(node)}.${key.name}`,
|
|
26082
|
+
default_modifier: (node, to_ctx) => x `${node} !== undefined ? ${node} : ${update_reference(contexts, n, value.right, to_ctx)}`,
|
|
26083
|
+
scope,
|
|
26084
|
+
component
|
|
26085
|
+
});
|
|
26018
26086
|
}
|
|
26019
26087
|
else {
|
|
26020
|
-
unpack_destructuring(
|
|
26088
|
+
unpack_destructuring({
|
|
26089
|
+
contexts,
|
|
26090
|
+
node: value,
|
|
26091
|
+
modifier: (node) => x `${modifier(node)}.${key.name}`,
|
|
26092
|
+
default_modifier,
|
|
26093
|
+
scope,
|
|
26094
|
+
component
|
|
26095
|
+
});
|
|
26021
26096
|
}
|
|
26022
26097
|
}
|
|
26023
26098
|
});
|
|
@@ -26048,6 +26123,18 @@ function update_reference(contexts, n, expression, to_ctx) {
|
|
|
26048
26123
|
});
|
|
26049
26124
|
return expression;
|
|
26050
26125
|
}
|
|
26126
|
+
function mark_referenced(node, scope, component) {
|
|
26127
|
+
walk(node, {
|
|
26128
|
+
enter(node, parent) {
|
|
26129
|
+
if (is_reference(node, parent)) {
|
|
26130
|
+
const { name } = flatten_reference(node);
|
|
26131
|
+
if (!scope.is_let(name) && !scope.names.has(name)) {
|
|
26132
|
+
component.add_reference(name);
|
|
26133
|
+
}
|
|
26134
|
+
}
|
|
26135
|
+
}
|
|
26136
|
+
});
|
|
26137
|
+
}
|
|
26051
26138
|
|
|
26052
26139
|
class AwaitBlock$1 extends Node$1 {
|
|
26053
26140
|
constructor(component, parent, scope, info) {
|
|
@@ -26057,11 +26144,11 @@ class AwaitBlock$1 extends Node$1 {
|
|
|
26057
26144
|
this.catch_node = info.error;
|
|
26058
26145
|
if (this.then_node) {
|
|
26059
26146
|
this.then_contexts = [];
|
|
26060
|
-
unpack_destructuring(this.then_contexts, info.value);
|
|
26147
|
+
unpack_destructuring({ contexts: this.then_contexts, node: info.value, scope, component });
|
|
26061
26148
|
}
|
|
26062
26149
|
if (this.catch_node) {
|
|
26063
26150
|
this.catch_contexts = [];
|
|
26064
|
-
unpack_destructuring(this.catch_contexts, info.error);
|
|
26151
|
+
unpack_destructuring({ contexts: this.catch_contexts, node: info.error, scope, component });
|
|
26065
26152
|
}
|
|
26066
26153
|
this.pending = new PendingBlock(component, this, scope, info.pending);
|
|
26067
26154
|
this.then = new ThenBlock(component, this, scope, info.then);
|
|
@@ -26157,7 +26244,7 @@ class EachBlock$1 extends AbstractBlock {
|
|
|
26157
26244
|
this.index = info.index;
|
|
26158
26245
|
this.scope = scope.child();
|
|
26159
26246
|
this.contexts = [];
|
|
26160
|
-
unpack_destructuring(this.contexts, info.context);
|
|
26247
|
+
unpack_destructuring({ contexts: this.contexts, node: info.context, scope, component });
|
|
26161
26248
|
this.contexts.forEach(context => {
|
|
26162
26249
|
this.scope.add(context.key.name, this.expression.dependencies, this);
|
|
26163
26250
|
});
|
|
@@ -26492,6 +26579,44 @@ const a11y_labelable = new Set([
|
|
|
26492
26579
|
'select',
|
|
26493
26580
|
'textarea'
|
|
26494
26581
|
]);
|
|
26582
|
+
const a11y_nested_implicit_semantics = new Map([
|
|
26583
|
+
['header', 'banner'],
|
|
26584
|
+
['footer', 'contentinfo']
|
|
26585
|
+
]);
|
|
26586
|
+
const a11y_implicit_semantics = new Map([
|
|
26587
|
+
['a', 'link'],
|
|
26588
|
+
['aside', 'complementary'],
|
|
26589
|
+
['body', 'document'],
|
|
26590
|
+
['datalist', 'listbox'],
|
|
26591
|
+
['dd', 'definition'],
|
|
26592
|
+
['dfn', 'term'],
|
|
26593
|
+
['details', 'group'],
|
|
26594
|
+
['dt', 'term'],
|
|
26595
|
+
['fieldset', 'group'],
|
|
26596
|
+
['form', 'form'],
|
|
26597
|
+
['h1', 'heading'],
|
|
26598
|
+
['h2', 'heading'],
|
|
26599
|
+
['h3', 'heading'],
|
|
26600
|
+
['h4', 'heading'],
|
|
26601
|
+
['h5', 'heading'],
|
|
26602
|
+
['h6', 'heading'],
|
|
26603
|
+
['hr', 'separator'],
|
|
26604
|
+
['li', 'listitem'],
|
|
26605
|
+
['menu', 'list'],
|
|
26606
|
+
['nav', 'navigation'],
|
|
26607
|
+
['ol', 'list'],
|
|
26608
|
+
['optgroup', 'group'],
|
|
26609
|
+
['output', 'status'],
|
|
26610
|
+
['progress', 'progressbar'],
|
|
26611
|
+
['section', 'region'],
|
|
26612
|
+
['summary', 'button'],
|
|
26613
|
+
['tbody', 'rowgroup'],
|
|
26614
|
+
['textarea', 'textbox'],
|
|
26615
|
+
['tfoot', 'rowgroup'],
|
|
26616
|
+
['thead', 'rowgroup'],
|
|
26617
|
+
['tr', 'row'],
|
|
26618
|
+
['ul', 'list']
|
|
26619
|
+
]);
|
|
26495
26620
|
const invisible_elements = new Set(['meta', 'html', 'script', 'style']);
|
|
26496
26621
|
const valid_modifiers = new Set([
|
|
26497
26622
|
'preventDefault',
|
|
@@ -26515,6 +26640,21 @@ const react_attributes = new Map([
|
|
|
26515
26640
|
['htmlFor', 'for']
|
|
26516
26641
|
]);
|
|
26517
26642
|
const attributes_to_compact_whitespace = ['class', 'style'];
|
|
26643
|
+
function is_parent(parent, elements) {
|
|
26644
|
+
let check = false;
|
|
26645
|
+
while (parent) {
|
|
26646
|
+
const parent_name = parent.name;
|
|
26647
|
+
if (elements.includes(parent_name)) {
|
|
26648
|
+
check = true;
|
|
26649
|
+
break;
|
|
26650
|
+
}
|
|
26651
|
+
if (parent.type === 'Element') {
|
|
26652
|
+
break;
|
|
26653
|
+
}
|
|
26654
|
+
parent = parent.parent;
|
|
26655
|
+
}
|
|
26656
|
+
return check;
|
|
26657
|
+
}
|
|
26518
26658
|
function get_namespace(parent, element, explicit_namespace) {
|
|
26519
26659
|
const parent_element = parent.find_nearest(/^Element/);
|
|
26520
26660
|
if (!parent_element) {
|
|
@@ -26720,6 +26860,19 @@ class Element$1 extends Node$1 {
|
|
|
26720
26860
|
const match = fuzzymatch(value, aria_roles);
|
|
26721
26861
|
component.warn(attribute, compiler_warnings.a11y_unknown_role(value, match));
|
|
26722
26862
|
}
|
|
26863
|
+
// no-redundant-roles
|
|
26864
|
+
const has_redundant_role = value === a11y_implicit_semantics.get(this.name);
|
|
26865
|
+
if (this.name === value || has_redundant_role) {
|
|
26866
|
+
component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value));
|
|
26867
|
+
}
|
|
26868
|
+
// Footers and headers are special cases, and should not have redundant roles unless they are the children of sections or articles.
|
|
26869
|
+
const is_parent_section_or_article = is_parent(this.parent, ['section', 'article']);
|
|
26870
|
+
if (!is_parent_section_or_article) {
|
|
26871
|
+
const has_nested_redundant_role = value === a11y_nested_implicit_semantics.get(this.name);
|
|
26872
|
+
if (has_nested_redundant_role) {
|
|
26873
|
+
component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value));
|
|
26874
|
+
}
|
|
26875
|
+
}
|
|
26723
26876
|
}
|
|
26724
26877
|
// no-access-key
|
|
26725
26878
|
if (name === 'accesskey') {
|
|
@@ -30149,7 +30302,7 @@ class Component {
|
|
|
30149
30302
|
if (result) {
|
|
30150
30303
|
const { compile_options, name } = this;
|
|
30151
30304
|
const { format = 'esm' } = compile_options;
|
|
30152
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.
|
|
30305
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.45.0'}`;
|
|
30153
30306
|
const program = { type: 'Program', body: result.js };
|
|
30154
30307
|
walk(program, {
|
|
30155
30308
|
enter: (node, parent, key) => {
|
|
@@ -31640,7 +31793,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
31640
31793
|
return result.to_processed();
|
|
31641
31794
|
}
|
|
31642
31795
|
|
|
31643
|
-
const VERSION = '3.
|
|
31796
|
+
const VERSION = '3.45.0';
|
|
31644
31797
|
|
|
31645
31798
|
export { VERSION, compile, parse$3 as parse, preprocess, walk };
|
|
31646
31799
|
//# sourceMappingURL=compiler.mjs.map
|