svelte 3.44.2 → 3.46.1

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE.md +1 -1
  3. package/compiler.js +19389 -18851
  4. package/compiler.js.map +1 -1
  5. package/compiler.mjs +19962 -19424
  6. package/compiler.mjs.map +1 -1
  7. package/internal/index.js +101 -28
  8. package/internal/index.mjs +100 -29
  9. package/package.json +4 -4
  10. package/types/compiler/compile/Component.d.ts +2 -2
  11. package/types/compiler/compile/nodes/CatchBlock.d.ts +2 -0
  12. package/types/compiler/compile/nodes/EachBlock.d.ts +2 -0
  13. package/types/compiler/compile/nodes/Element.d.ts +2 -0
  14. package/types/compiler/compile/nodes/SlotTemplate.d.ts +2 -0
  15. package/types/compiler/compile/nodes/Style.d.ts +12 -0
  16. package/types/compiler/compile/nodes/StyleDirective.d.ts +12 -0
  17. package/types/compiler/compile/nodes/ThenBlock.d.ts +2 -0
  18. package/types/compiler/compile/nodes/interfaces.d.ts +4 -2
  19. package/types/compiler/compile/nodes/shared/Context.d.ts +10 -1
  20. package/types/compiler/compile/nodes/shared/Expression.d.ts +1 -1
  21. package/types/compiler/compile/nodes/shared/TemplateScope.d.ts +3 -1
  22. package/types/compiler/compile/nodes/shared/map_children.d.ts +2 -1
  23. package/types/compiler/compile/render_dom/Renderer.d.ts +1 -1
  24. package/types/compiler/compile/render_dom/wrappers/AwaitBlock.d.ts +2 -1
  25. package/types/compiler/compile/render_dom/wrappers/Element/Binding.d.ts +1 -0
  26. package/types/compiler/compile/render_dom/wrappers/Element/index.d.ts +1 -0
  27. package/types/compiler/compile/render_dom/wrappers/SlotTemplate.d.ts +4 -11
  28. package/types/compiler/compile/render_ssr/handlers/SlotTemplate.d.ts +1 -3
  29. package/types/compiler/compile/utils/nodes_to_template_literal.d.ts +7 -0
  30. package/types/compiler/interfaces.d.ts +18 -6
  31. package/types/compiler/utils/namespaces.d.ts +1 -1
  32. package/types/runtime/internal/dom.d.ts +1 -1
  33. package/types/runtime/internal/ssr.d.ts +3 -1
package/internal/index.js CHANGED
@@ -333,7 +333,7 @@ function get_root_for_style(node) {
333
333
  function append_empty_stylesheet(node) {
334
334
  const style_element = element('style');
335
335
  append_stylesheet(get_root_for_style(node), style_element);
336
- return style_element;
336
+ return style_element.sheet;
337
337
  }
338
338
  function append_stylesheet(node, style) {
339
339
  append(node.head || node, style);
@@ -619,7 +619,7 @@ function claim_html_tag(nodes) {
619
619
  return new HtmlTagHydration();
620
620
  }
621
621
  init_claim_info(nodes);
622
- const html_tag_nodes = nodes.splice(start_index, end_index + 1);
622
+ const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);
623
623
  detach(html_tag_nodes[0]);
624
624
  detach(html_tag_nodes[html_tag_nodes.length - 1]);
625
625
  const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);
@@ -646,7 +646,12 @@ function set_input_type(input, type) {
646
646
  }
647
647
  }
648
648
  function set_style(node, key, value, important) {
649
- node.style.setProperty(key, value, important ? 'important' : '');
649
+ if (value === null) {
650
+ node.style.removeProperty(key);
651
+ }
652
+ else {
653
+ node.style.setProperty(key, value, important ? 'important' : '');
654
+ }
650
655
  }
651
656
  function select_option(select, value) {
652
657
  for (let i = 0; i < select.options.length; i += 1) {
@@ -803,7 +808,9 @@ function get_custom_elements_slots(element) {
803
808
  return result;
804
809
  }
805
810
 
806
- const active_docs = new Set();
811
+ // we need to store the information for multiple documents because a Svelte application could also contain iframes
812
+ // https://github.com/sveltejs/svelte/issues/3624
813
+ const managed_styles = new Map();
807
814
  let active = 0;
808
815
  // https://github.com/darkskyapp/string-hash/blob/master/index.js
809
816
  function hash(str) {
@@ -813,6 +820,11 @@ function hash(str) {
813
820
  hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
814
821
  return hash >>> 0;
815
822
  }
823
+ function create_style_information(doc, node) {
824
+ const info = { stylesheet: append_empty_stylesheet(node), rules: {} };
825
+ managed_styles.set(doc, info);
826
+ return info;
827
+ }
816
828
  function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
817
829
  const step = 16.666 / duration;
818
830
  let keyframes = '{\n';
@@ -823,11 +835,9 @@ function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
823
835
  const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
824
836
  const name = `__svelte_${hash(rule)}_${uid}`;
825
837
  const doc = get_root_for_style(node);
826
- active_docs.add(doc);
827
- const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = append_empty_stylesheet(node).sheet);
828
- const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});
829
- if (!current_rules[name]) {
830
- current_rules[name] = true;
838
+ const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node);
839
+ if (!rules[name]) {
840
+ rules[name] = true;
831
841
  stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
832
842
  }
833
843
  const animation = node.style.animation || '';
@@ -853,14 +863,14 @@ function clear_rules() {
853
863
  exports.raf(() => {
854
864
  if (active)
855
865
  return;
856
- active_docs.forEach(doc => {
857
- const stylesheet = doc.__svelte_stylesheet;
866
+ managed_styles.forEach(info => {
867
+ const { stylesheet } = info;
858
868
  let i = stylesheet.cssRules.length;
859
869
  while (i--)
860
870
  stylesheet.deleteRule(i);
861
- doc.__svelte_rules = {};
871
+ info.rules = {};
862
872
  });
863
- active_docs.clear();
873
+ managed_styles.clear();
864
874
  });
865
875
  }
866
876
 
@@ -1013,22 +1023,40 @@ function add_render_callback(fn) {
1013
1023
  function add_flush_callback(fn) {
1014
1024
  flush_callbacks.push(fn);
1015
1025
  }
1016
- let flushing = false;
1026
+ // flush() calls callbacks in this order:
1027
+ // 1. All beforeUpdate callbacks, in order: parents before children
1028
+ // 2. All bind:this callbacks, in reverse order: children before parents.
1029
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
1030
+ // for afterUpdates called during the initial onMount, which are called in
1031
+ // reverse order: children before parents.
1032
+ // Since callbacks might update component values, which could trigger another
1033
+ // call to flush(), the following steps guard against this:
1034
+ // 1. During beforeUpdate, any updated components will be added to the
1035
+ // dirty_components array and will cause a reentrant call to flush(). Because
1036
+ // the flush index is kept outside the function, the reentrant call will pick
1037
+ // up where the earlier call left off and go through all dirty components. The
1038
+ // current_component value is saved and restored so that the reentrant call will
1039
+ // not interfere with the "parent" flush() call.
1040
+ // 2. bind:this callbacks cannot trigger new flush() calls.
1041
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
1042
+ // callback called a second time; the seen_callbacks set, outside the flush()
1043
+ // function, guarantees this behavior.
1017
1044
  const seen_callbacks = new Set();
1045
+ let flushidx = 0; // Do *not* move this inside the flush() function
1018
1046
  function flush() {
1019
- if (flushing)
1020
- return;
1021
- flushing = true;
1047
+ const saved_component = exports.current_component;
1022
1048
  do {
1023
1049
  // first, call beforeUpdate functions
1024
1050
  // and update components
1025
- for (let i = 0; i < dirty_components.length; i += 1) {
1026
- const component = dirty_components[i];
1051
+ while (flushidx < dirty_components.length) {
1052
+ const component = dirty_components[flushidx];
1053
+ flushidx++;
1027
1054
  set_current_component(component);
1028
1055
  update(component.$$);
1029
1056
  }
1030
1057
  set_current_component(null);
1031
1058
  dirty_components.length = 0;
1059
+ flushidx = 0;
1032
1060
  while (binding_callbacks.length)
1033
1061
  binding_callbacks.pop()();
1034
1062
  // then, once components are updated, call
@@ -1048,8 +1076,8 @@ function flush() {
1048
1076
  flush_callbacks.pop()();
1049
1077
  }
1050
1078
  update_scheduled = false;
1051
- flushing = false;
1052
1079
  seen_callbacks.clear();
1080
+ set_current_component(saved_component);
1053
1081
  }
1054
1082
  function update($$) {
1055
1083
  if ($$.fragment !== null) {
@@ -1597,14 +1625,26 @@ const boolean_attributes = new Set([
1597
1625
  const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1598
1626
  // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1599
1627
  // https://infra.spec.whatwg.org/#noncharacter
1600
- function spread(args, classes_to_add) {
1628
+ function spread(args, attrs_to_add) {
1601
1629
  const attributes = Object.assign({}, ...args);
1602
- if (classes_to_add) {
1603
- if (attributes.class == null) {
1604
- attributes.class = classes_to_add;
1630
+ if (attrs_to_add) {
1631
+ const classes_to_add = attrs_to_add.classes;
1632
+ const styles_to_add = attrs_to_add.styles;
1633
+ if (classes_to_add) {
1634
+ if (attributes.class == null) {
1635
+ attributes.class = classes_to_add;
1636
+ }
1637
+ else {
1638
+ attributes.class += ' ' + classes_to_add;
1639
+ }
1605
1640
  }
1606
- else {
1607
- attributes.class += ' ' + classes_to_add;
1641
+ if (styles_to_add) {
1642
+ if (attributes.style == null) {
1643
+ attributes.style = style_object_to_string(styles_to_add);
1644
+ }
1645
+ else {
1646
+ attributes.style = style_object_to_string(merge_ssr_styles(attributes.style, styles_to_add));
1647
+ }
1608
1648
  }
1609
1649
  }
1610
1650
  let str = '';
@@ -1624,6 +1664,27 @@ function spread(args, classes_to_add) {
1624
1664
  });
1625
1665
  return str;
1626
1666
  }
1667
+ function merge_ssr_styles(style_attribute, style_directive) {
1668
+ const style_object = {};
1669
+ for (const individual_style of style_attribute.split(';')) {
1670
+ const colon_index = individual_style.indexOf(':');
1671
+ const name = individual_style.slice(0, colon_index).trim();
1672
+ const value = individual_style.slice(colon_index + 1).trim();
1673
+ if (!name)
1674
+ continue;
1675
+ style_object[name] = value;
1676
+ }
1677
+ for (const name in style_directive) {
1678
+ const value = style_directive[name];
1679
+ if (value) {
1680
+ style_object[name] = value;
1681
+ }
1682
+ else {
1683
+ delete style_object[name];
1684
+ }
1685
+ }
1686
+ return style_object;
1687
+ }
1627
1688
  const escaped = {
1628
1689
  '"': '&quot;',
1629
1690
  "'": '&#39;',
@@ -1706,11 +1767,21 @@ function create_ssr_component(fn) {
1706
1767
  function add_attribute(name, value, boolean) {
1707
1768
  if (value == null || (boolean && !value))
1708
1769
  return '';
1709
- return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `"${value}"`}`}`;
1770
+ return ` ${name}${value === true && boolean_attributes.has(name) ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `"${value}"`}`}`;
1710
1771
  }
1711
1772
  function add_classes(classes) {
1712
1773
  return classes ? ` class="${classes}"` : '';
1713
1774
  }
1775
+ function style_object_to_string(style_object) {
1776
+ return Object.keys(style_object)
1777
+ .filter(key => style_object[key])
1778
+ .map(key => `${key}: ${style_object[key]};`)
1779
+ .join(' ');
1780
+ }
1781
+ function add_styles(style_object) {
1782
+ const styles = style_object_to_string(style_object);
1783
+ return styles ? ` style="${styles}"` : '';
1784
+ }
1714
1785
 
1715
1786
  function bind(component, name, callback) {
1716
1787
  const index = component.$$.props[name];
@@ -1898,7 +1969,7 @@ class SvelteComponent {
1898
1969
  }
1899
1970
 
1900
1971
  function dispatch_dev(type, detail) {
1901
- document.dispatchEvent(custom_event(type, Object.assign({ version: '3.44.2' }, detail), true));
1972
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.46.1' }, detail), true));
1902
1973
  }
1903
1974
  function append_dev(target, node) {
1904
1975
  dispatch_dev('SvelteDOMInsert', { target, node });
@@ -2062,6 +2133,7 @@ exports.add_flush_callback = add_flush_callback;
2062
2133
  exports.add_location = add_location;
2063
2134
  exports.add_render_callback = add_render_callback;
2064
2135
  exports.add_resize_listener = add_resize_listener;
2136
+ exports.add_styles = add_styles;
2065
2137
  exports.add_transform = add_transform;
2066
2138
  exports.afterUpdate = afterUpdate;
2067
2139
  exports.append = append;
@@ -2159,6 +2231,7 @@ exports.listen = listen;
2159
2231
  exports.listen_dev = listen_dev;
2160
2232
  exports.loop = loop;
2161
2233
  exports.loop_guard = loop_guard;
2234
+ exports.merge_ssr_styles = merge_ssr_styles;
2162
2235
  exports.missing_component = missing_component;
2163
2236
  exports.mount_component = mount_component;
2164
2237
  exports.noop = noop;
@@ -329,7 +329,7 @@ function get_root_for_style(node) {
329
329
  function append_empty_stylesheet(node) {
330
330
  const style_element = element('style');
331
331
  append_stylesheet(get_root_for_style(node), style_element);
332
- return style_element;
332
+ return style_element.sheet;
333
333
  }
334
334
  function append_stylesheet(node, style) {
335
335
  append(node.head || node, style);
@@ -615,7 +615,7 @@ function claim_html_tag(nodes) {
615
615
  return new HtmlTagHydration();
616
616
  }
617
617
  init_claim_info(nodes);
618
- const html_tag_nodes = nodes.splice(start_index, end_index + 1);
618
+ const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);
619
619
  detach(html_tag_nodes[0]);
620
620
  detach(html_tag_nodes[html_tag_nodes.length - 1]);
621
621
  const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);
@@ -642,7 +642,12 @@ function set_input_type(input, type) {
642
642
  }
643
643
  }
644
644
  function set_style(node, key, value, important) {
645
- node.style.setProperty(key, value, important ? 'important' : '');
645
+ if (value === null) {
646
+ node.style.removeProperty(key);
647
+ }
648
+ else {
649
+ node.style.setProperty(key, value, important ? 'important' : '');
650
+ }
646
651
  }
647
652
  function select_option(select, value) {
648
653
  for (let i = 0; i < select.options.length; i += 1) {
@@ -799,7 +804,9 @@ function get_custom_elements_slots(element) {
799
804
  return result;
800
805
  }
801
806
 
802
- const active_docs = new Set();
807
+ // we need to store the information for multiple documents because a Svelte application could also contain iframes
808
+ // https://github.com/sveltejs/svelte/issues/3624
809
+ const managed_styles = new Map();
803
810
  let active = 0;
804
811
  // https://github.com/darkskyapp/string-hash/blob/master/index.js
805
812
  function hash(str) {
@@ -809,6 +816,11 @@ function hash(str) {
809
816
  hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
810
817
  return hash >>> 0;
811
818
  }
819
+ function create_style_information(doc, node) {
820
+ const info = { stylesheet: append_empty_stylesheet(node), rules: {} };
821
+ managed_styles.set(doc, info);
822
+ return info;
823
+ }
812
824
  function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
813
825
  const step = 16.666 / duration;
814
826
  let keyframes = '{\n';
@@ -819,11 +831,9 @@ function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
819
831
  const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
820
832
  const name = `__svelte_${hash(rule)}_${uid}`;
821
833
  const doc = get_root_for_style(node);
822
- active_docs.add(doc);
823
- const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = append_empty_stylesheet(node).sheet);
824
- const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});
825
- if (!current_rules[name]) {
826
- current_rules[name] = true;
834
+ const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node);
835
+ if (!rules[name]) {
836
+ rules[name] = true;
827
837
  stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
828
838
  }
829
839
  const animation = node.style.animation || '';
@@ -849,14 +859,14 @@ function clear_rules() {
849
859
  raf(() => {
850
860
  if (active)
851
861
  return;
852
- active_docs.forEach(doc => {
853
- const stylesheet = doc.__svelte_stylesheet;
862
+ managed_styles.forEach(info => {
863
+ const { stylesheet } = info;
854
864
  let i = stylesheet.cssRules.length;
855
865
  while (i--)
856
866
  stylesheet.deleteRule(i);
857
- doc.__svelte_rules = {};
867
+ info.rules = {};
858
868
  });
859
- active_docs.clear();
869
+ managed_styles.clear();
860
870
  });
861
871
  }
862
872
 
@@ -1010,22 +1020,40 @@ function add_render_callback(fn) {
1010
1020
  function add_flush_callback(fn) {
1011
1021
  flush_callbacks.push(fn);
1012
1022
  }
1013
- let flushing = false;
1023
+ // flush() calls callbacks in this order:
1024
+ // 1. All beforeUpdate callbacks, in order: parents before children
1025
+ // 2. All bind:this callbacks, in reverse order: children before parents.
1026
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
1027
+ // for afterUpdates called during the initial onMount, which are called in
1028
+ // reverse order: children before parents.
1029
+ // Since callbacks might update component values, which could trigger another
1030
+ // call to flush(), the following steps guard against this:
1031
+ // 1. During beforeUpdate, any updated components will be added to the
1032
+ // dirty_components array and will cause a reentrant call to flush(). Because
1033
+ // the flush index is kept outside the function, the reentrant call will pick
1034
+ // up where the earlier call left off and go through all dirty components. The
1035
+ // current_component value is saved and restored so that the reentrant call will
1036
+ // not interfere with the "parent" flush() call.
1037
+ // 2. bind:this callbacks cannot trigger new flush() calls.
1038
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
1039
+ // callback called a second time; the seen_callbacks set, outside the flush()
1040
+ // function, guarantees this behavior.
1014
1041
  const seen_callbacks = new Set();
1042
+ let flushidx = 0; // Do *not* move this inside the flush() function
1015
1043
  function flush() {
1016
- if (flushing)
1017
- return;
1018
- flushing = true;
1044
+ const saved_component = current_component;
1019
1045
  do {
1020
1046
  // first, call beforeUpdate functions
1021
1047
  // and update components
1022
- for (let i = 0; i < dirty_components.length; i += 1) {
1023
- const component = dirty_components[i];
1048
+ while (flushidx < dirty_components.length) {
1049
+ const component = dirty_components[flushidx];
1050
+ flushidx++;
1024
1051
  set_current_component(component);
1025
1052
  update(component.$$);
1026
1053
  }
1027
1054
  set_current_component(null);
1028
1055
  dirty_components.length = 0;
1056
+ flushidx = 0;
1029
1057
  while (binding_callbacks.length)
1030
1058
  binding_callbacks.pop()();
1031
1059
  // then, once components are updated, call
@@ -1045,8 +1073,8 @@ function flush() {
1045
1073
  flush_callbacks.pop()();
1046
1074
  }
1047
1075
  update_scheduled = false;
1048
- flushing = false;
1049
1076
  seen_callbacks.clear();
1077
+ set_current_component(saved_component);
1050
1078
  }
1051
1079
  function update($$) {
1052
1080
  if ($$.fragment !== null) {
@@ -1594,14 +1622,26 @@ const boolean_attributes = new Set([
1594
1622
  const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
1595
1623
  // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
1596
1624
  // https://infra.spec.whatwg.org/#noncharacter
1597
- function spread(args, classes_to_add) {
1625
+ function spread(args, attrs_to_add) {
1598
1626
  const attributes = Object.assign({}, ...args);
1599
- if (classes_to_add) {
1600
- if (attributes.class == null) {
1601
- attributes.class = classes_to_add;
1627
+ if (attrs_to_add) {
1628
+ const classes_to_add = attrs_to_add.classes;
1629
+ const styles_to_add = attrs_to_add.styles;
1630
+ if (classes_to_add) {
1631
+ if (attributes.class == null) {
1632
+ attributes.class = classes_to_add;
1633
+ }
1634
+ else {
1635
+ attributes.class += ' ' + classes_to_add;
1636
+ }
1602
1637
  }
1603
- else {
1604
- attributes.class += ' ' + classes_to_add;
1638
+ if (styles_to_add) {
1639
+ if (attributes.style == null) {
1640
+ attributes.style = style_object_to_string(styles_to_add);
1641
+ }
1642
+ else {
1643
+ attributes.style = style_object_to_string(merge_ssr_styles(attributes.style, styles_to_add));
1644
+ }
1605
1645
  }
1606
1646
  }
1607
1647
  let str = '';
@@ -1621,6 +1661,27 @@ function spread(args, classes_to_add) {
1621
1661
  });
1622
1662
  return str;
1623
1663
  }
1664
+ function merge_ssr_styles(style_attribute, style_directive) {
1665
+ const style_object = {};
1666
+ for (const individual_style of style_attribute.split(';')) {
1667
+ const colon_index = individual_style.indexOf(':');
1668
+ const name = individual_style.slice(0, colon_index).trim();
1669
+ const value = individual_style.slice(colon_index + 1).trim();
1670
+ if (!name)
1671
+ continue;
1672
+ style_object[name] = value;
1673
+ }
1674
+ for (const name in style_directive) {
1675
+ const value = style_directive[name];
1676
+ if (value) {
1677
+ style_object[name] = value;
1678
+ }
1679
+ else {
1680
+ delete style_object[name];
1681
+ }
1682
+ }
1683
+ return style_object;
1684
+ }
1624
1685
  const escaped = {
1625
1686
  '"': '&quot;',
1626
1687
  "'": '&#39;',
@@ -1703,11 +1764,21 @@ function create_ssr_component(fn) {
1703
1764
  function add_attribute(name, value, boolean) {
1704
1765
  if (value == null || (boolean && !value))
1705
1766
  return '';
1706
- return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `"${value}"`}`}`;
1767
+ return ` ${name}${value === true && boolean_attributes.has(name) ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `"${value}"`}`}`;
1707
1768
  }
1708
1769
  function add_classes(classes) {
1709
1770
  return classes ? ` class="${classes}"` : '';
1710
1771
  }
1772
+ function style_object_to_string(style_object) {
1773
+ return Object.keys(style_object)
1774
+ .filter(key => style_object[key])
1775
+ .map(key => `${key}: ${style_object[key]};`)
1776
+ .join(' ');
1777
+ }
1778
+ function add_styles(style_object) {
1779
+ const styles = style_object_to_string(style_object);
1780
+ return styles ? ` style="${styles}"` : '';
1781
+ }
1711
1782
 
1712
1783
  function bind(component, name, callback) {
1713
1784
  const index = component.$$.props[name];
@@ -1896,7 +1967,7 @@ class SvelteComponent {
1896
1967
  }
1897
1968
 
1898
1969
  function dispatch_dev(type, detail) {
1899
- document.dispatchEvent(custom_event(type, Object.assign({ version: '3.44.2' }, detail), true));
1970
+ document.dispatchEvent(custom_event(type, Object.assign({ version: '3.46.1' }, detail), true));
1900
1971
  }
1901
1972
  function append_dev(target, node) {
1902
1973
  dispatch_dev('SvelteDOMInsert', { target, node });
@@ -2048,4 +2119,4 @@ function loop_guard(timeout) {
2048
2119
  };
2049
2120
  }
2050
2121
 
2051
- export { HtmlTag, HtmlTagHydration, SvelteComponent, SvelteComponentDev, SvelteComponentTyped, SvelteElement, action_destroyer, add_attribute, add_classes, add_flush_callback, add_location, add_render_callback, add_resize_listener, add_transform, afterUpdate, append, append_dev, append_empty_stylesheet, append_hydration, append_hydration_dev, append_styles, assign, attr, attr_dev, attribute_to_object, beforeUpdate, bind, binding_callbacks, blank_object, bubble, check_outros, children, claim_component, claim_element, claim_html_tag, claim_space, claim_svg_element, claim_text, clear_loops, component_subscribe, compute_rest_props, compute_slots, createEventDispatcher, create_animation, create_bidirectional_transition, create_component, create_in_transition, create_out_transition, create_slot, create_ssr_component, current_component, custom_event, dataset_dev, debug, destroy_block, destroy_component, destroy_each, detach, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dirty_components, dispatch_dev, each, element, element_is, empty, end_hydrating, escape, escape_attribute_value, escape_object, escaped, exclude_internal_props, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, getAllContexts, getContext, get_all_dirty_from_scope, get_binding_group_value, get_current_component, get_custom_elements_slots, get_root_for_style, get_slot_changes, get_spread_object, get_spread_update, get_store_value, globals, group_outros, handle_promise, hasContext, has_prop, identity, init, insert, insert_dev, insert_hydration, insert_hydration_dev, intros, invalid_attribute_name_character, is_client, is_crossorigin, is_empty, is_function, is_promise, listen, listen_dev, loop, loop_guard, missing_component, mount_component, noop, not_equal, now, null_to_empty, object_without_properties, onDestroy, onMount, once, outro_and_destroy_block, prevent_default, prop_dev, query_selector_all, raf, run, run_all, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_current_component, set_custom_element_data, set_data, set_data_dev, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, spread, src_url_equal, start_hydrating, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, transition_in, transition_out, trusted, update_await_block_branch, update_keyed_each, update_slot, update_slot_base, validate_component, validate_each_argument, validate_each_keys, validate_slots, validate_store, xlink_attr };
2122
+ export { HtmlTag, HtmlTagHydration, SvelteComponent, SvelteComponentDev, SvelteComponentTyped, SvelteElement, action_destroyer, add_attribute, add_classes, add_flush_callback, add_location, add_render_callback, add_resize_listener, add_styles, add_transform, afterUpdate, append, append_dev, append_empty_stylesheet, append_hydration, append_hydration_dev, append_styles, assign, attr, attr_dev, attribute_to_object, beforeUpdate, bind, binding_callbacks, blank_object, bubble, check_outros, children, claim_component, claim_element, claim_html_tag, claim_space, claim_svg_element, claim_text, clear_loops, component_subscribe, compute_rest_props, compute_slots, createEventDispatcher, create_animation, create_bidirectional_transition, create_component, create_in_transition, create_out_transition, create_slot, create_ssr_component, current_component, custom_event, dataset_dev, debug, destroy_block, destroy_component, destroy_each, detach, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dirty_components, dispatch_dev, each, element, element_is, empty, end_hydrating, escape, escape_attribute_value, escape_object, escaped, exclude_internal_props, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, getAllContexts, getContext, get_all_dirty_from_scope, get_binding_group_value, get_current_component, get_custom_elements_slots, get_root_for_style, get_slot_changes, get_spread_object, get_spread_update, get_store_value, globals, group_outros, handle_promise, hasContext, has_prop, identity, init, insert, insert_dev, insert_hydration, insert_hydration_dev, intros, invalid_attribute_name_character, is_client, is_crossorigin, is_empty, is_function, is_promise, listen, listen_dev, loop, loop_guard, merge_ssr_styles, missing_component, mount_component, noop, not_equal, now, null_to_empty, object_without_properties, onDestroy, onMount, once, outro_and_destroy_block, prevent_default, prop_dev, query_selector_all, raf, run, run_all, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_current_component, set_custom_element_data, set_data, set_data_dev, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, spread, src_url_equal, start_hydrating, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, transition_in, transition_out, trusted, update_await_block_branch, update_keyed_each, update_slot, update_slot_base, validate_component, validate_each_argument, validate_each_keys, validate_slots, validate_store, xlink_attr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte",
3
- "version": "3.44.2",
3
+ "version": "3.46.1",
4
4
  "description": "Cybernetically enhanced web apps",
5
5
  "module": "index.mjs",
6
6
  "main": "index",
@@ -83,8 +83,8 @@
83
83
  },
84
84
  "types": "types/runtime/index.d.ts",
85
85
  "scripts": {
86
- "test": "mocha",
87
- "test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts",
86
+ "test": "mocha --exit",
87
+ "test:unit": "mocha --require sucrase/register --recursive src/**/__test__.ts --exit",
88
88
  "quicktest": "mocha",
89
89
  "precoverage": "c8 mocha",
90
90
  "coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html",
@@ -132,7 +132,7 @@
132
132
  "acorn": "^8.4.1",
133
133
  "agadoo": "^1.1.0",
134
134
  "c8": "^5.0.1",
135
- "code-red": "^0.2.3",
135
+ "code-red": "^0.2.4",
136
136
  "codecov": "^3.5.0",
137
137
  "css-tree": "^1.1.2",
138
138
  "eslint": "^7.32.0",
@@ -5,7 +5,7 @@ import Fragment from './nodes/Fragment';
5
5
  import { Ast, CompileOptions, Var, Warning, CssResult } from '../interfaces';
6
6
  import TemplateScope from './nodes/shared/TemplateScope';
7
7
  import Slot from './nodes/Slot';
8
- import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier } from 'estree';
8
+ import { Node, ImportDeclaration, ExportNamedDeclaration, Identifier, FunctionDeclaration } from 'estree';
9
9
  import Element from './nodes/Element';
10
10
  interface ComponentOptions {
11
11
  namespace?: string;
@@ -104,7 +104,7 @@ export default class Component {
104
104
  message: string;
105
105
  }): void;
106
106
  extract_imports(node: any): void;
107
- extract_exports(node: any, module_script?: boolean): void | import("estree").FunctionDeclaration | import("estree").VariableDeclaration | import("estree").ClassDeclaration;
107
+ extract_exports(node: any, module_script?: boolean): void | FunctionDeclaration | import("estree").VariableDeclaration | import("estree").ClassDeclaration;
108
108
  private _extract_exports;
109
109
  extract_javascript(script: any): any;
110
110
  walk_module_js(): void;
@@ -3,8 +3,10 @@ import AbstractBlock from './shared/AbstractBlock';
3
3
  import AwaitBlock from './AwaitBlock';
4
4
  import Component from '../Component';
5
5
  import { TemplateNode } from '../../interfaces';
6
+ import ConstTag from './ConstTag';
6
7
  export default class CatchBlock extends AbstractBlock {
7
8
  type: 'CatchBlock';
8
9
  scope: TemplateScope;
10
+ const_tags: ConstTag[];
9
11
  constructor(component: Component, parent: AwaitBlock, scope: TemplateScope, info: TemplateNode);
10
12
  }
@@ -2,6 +2,7 @@ import ElseBlock from './ElseBlock';
2
2
  import Expression from './shared/Expression';
3
3
  import TemplateScope from './shared/TemplateScope';
4
4
  import AbstractBlock from './shared/AbstractBlock';
5
+ import ConstTag from './ConstTag';
5
6
  import { Context } from './shared/Context';
6
7
  import { Node } from 'estree';
7
8
  import Component from '../Component';
@@ -16,6 +17,7 @@ export default class EachBlock extends AbstractBlock {
16
17
  key: Expression;
17
18
  scope: TemplateScope;
18
19
  contexts: Context[];
20
+ const_tags: ConstTag[];
19
21
  has_animation: boolean;
20
22
  has_binding: boolean;
21
23
  has_index_binding: boolean;
@@ -6,6 +6,7 @@ import Transition from './Transition';
6
6
  import Animation from './Animation';
7
7
  import Action from './Action';
8
8
  import Class from './Class';
9
+ import StyleDirective from './StyleDirective';
9
10
  import Let from './Let';
10
11
  import TemplateScope from './shared/TemplateScope';
11
12
  import { INode } from './interfaces';
@@ -18,6 +19,7 @@ export default class Element extends Node {
18
19
  actions: Action[];
19
20
  bindings: Binding[];
20
21
  classes: Class[];
22
+ styles: StyleDirective[];
21
23
  handlers: EventHandler[];
22
24
  lets: Let[];
23
25
  intro?: Transition;
@@ -4,11 +4,13 @@ import Node from './shared/Node';
4
4
  import Let from './Let';
5
5
  import Attribute from './Attribute';
6
6
  import { INode } from './interfaces';
7
+ import ConstTag from './ConstTag';
7
8
  export default class SlotTemplate extends Node {
8
9
  type: 'SlotTemplate';
9
10
  scope: TemplateScope;
10
11
  children: INode[];
11
12
  lets: Let[];
13
+ const_tags: ConstTag[];
12
14
  slot_attribute: Attribute;
13
15
  slot_template_name: string;
14
16
  constructor(component: Component, parent: INode, scope: TemplateScope, info: any);
@@ -0,0 +1,12 @@
1
+ import Node from './shared/Node';
2
+ import Expression from './shared/Expression';
3
+ import { TemplateNode } from '../../interfaces';
4
+ import TemplateScope from './shared/TemplateScope';
5
+ import Component from '../Component';
6
+ export default class Style extends Node {
7
+ type: 'Style';
8
+ name: string;
9
+ expression: Expression;
10
+ should_cache: boolean;
11
+ constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
12
+ }
@@ -0,0 +1,12 @@
1
+ import { TemplateNode } from '../../interfaces';
2
+ import Component from '../Component';
3
+ import Expression from './shared/Expression';
4
+ import Node from './shared/Node';
5
+ import TemplateScope from './shared/TemplateScope';
6
+ export default class StyleDirective extends Node {
7
+ type: 'StyleDirective';
8
+ name: string;
9
+ expression: Expression;
10
+ should_cache: boolean;
11
+ constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode);
12
+ }
@@ -3,8 +3,10 @@ import AbstractBlock from './shared/AbstractBlock';
3
3
  import AwaitBlock from './AwaitBlock';
4
4
  import Component from '../Component';
5
5
  import { TemplateNode } from '../../interfaces';
6
+ import ConstTag from './ConstTag';
6
7
  export default class ThenBlock extends AbstractBlock {
7
8
  type: 'ThenBlock';
8
9
  scope: TemplateScope;
10
+ const_tags: ConstTag[];
9
11
  constructor(component: Component, parent: AwaitBlock, scope: TemplateScope, info: TemplateNode);
10
12
  }