Skip to content

Commit

Permalink
Merge pull request #3 from sveltejs/main
Browse files Browse the repository at this point in the history
pull
  • Loading branch information
adiguba authored Dec 23, 2023
2 parents e496370 + eab690d commit 35c3601
Show file tree
Hide file tree
Showing 74 changed files with 947 additions and 113 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-rabbits-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve props aliasing
5 changes: 5 additions & 0 deletions .changeset/chatty-cups-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

feat: add support for `{@const}` inside snippet block
5 changes: 5 additions & 0 deletions .changeset/dull-mangos-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve whitespace handling
5 changes: 5 additions & 0 deletions .changeset/four-flies-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve each block fallback handling
5 changes: 5 additions & 0 deletions .changeset/happy-suits-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve attribute directive reactivity detection
5 changes: 5 additions & 0 deletions .changeset/heavy-ears-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve $inspect batching
5 changes: 5 additions & 0 deletions .changeset/large-turkeys-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: improve readonly prop messaging
5 changes: 5 additions & 0 deletions .changeset/late-crabs-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

feat: add `gamepadconnected` and `gamepaddisconnected` events
5 changes: 5 additions & 0 deletions .changeset/lovely-carpets-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: better handle array property deletion reactivity
18 changes: 18 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"changesets": [
"afraid-moose-matter",
"beige-flies-wash",
"beige-rabbits-shave",
"brave-walls-destroy",
"brown-spoons-boil",
"chatty-cups-drop",
"chatty-taxis-juggle",
"chilled-pumas-invite",
"chilly-dolphins-lick",
Expand All @@ -24,6 +26,7 @@
"curly-lizards-dream",
"dirty-garlics-design",
"dirty-tips-add",
"dull-mangos-wave",
"early-ads-tie",
"eight-steaks-shout",
"eighty-bikes-camp",
Expand All @@ -36,6 +39,7 @@
"five-tigers-search",
"flat-melons-protect",
"forty-comics-invent",
"four-flies-hammer",
"fresh-weeks-trade",
"friendly-lies-camp",
"funny-wombats-argue",
Expand All @@ -45,7 +49,9 @@
"great-icons-retire",
"green-eggs-approve",
"green-hounds-play",
"happy-suits-film",
"healthy-planes-vanish",
"heavy-ears-rule",
"honest-icons-change",
"hungry-dots-fry",
"hungry-tips-unite",
Expand All @@ -56,12 +62,15 @@
"kind-deers-lay",
"kind-eagles-join",
"large-clouds-carry",
"large-turkeys-deny",
"late-crabs-lay",
"lazy-masks-sit",
"lazy-months-knock",
"lazy-spiders-think",
"lemon-geese-drum",
"light-pens-watch",
"long-crews-return",
"lovely-carpets-lick",
"lovely-items-turn",
"lovely-rules-eat",
"lucky-schools-hang",
Expand All @@ -81,10 +90,13 @@
"poor-eggs-enjoy",
"poor-seahorses-flash",
"popular-mangos-rest",
"purple-dragons-peel",
"quiet-camels-mate",
"rare-pears-whisper",
"real-guests-do",
"rich-sheep-burn",
"rich-tables-sing",
"rotten-bags-type",
"rotten-buckets-develop",
"selfish-tools-hide",
"serious-socks-cover",
Expand All @@ -96,6 +108,7 @@
"shiny-baboons-play",
"shiny-shrimps-march",
"slimy-clouds-talk",
"slow-chefs-dream",
"small-papayas-laugh",
"smart-parents-swim",
"soft-clocks-remember",
Expand All @@ -104,15 +117,18 @@
"sour-rules-march",
"spicy-plums-admire",
"stale-comics-look",
"strong-gifts-smoke",
"strong-lemons-provide",
"sweet-mangos-beg",
"swift-donkeys-perform",
"swift-ravens-hunt",
"swift-seahorses-deliver",
"tall-books-grin",
"tall-shrimps-worry",
"tall-tigers-wait",
"tasty-numbers-perform",
"ten-foxes-repeat",
"ten-peaches-sleep",
"ten-worms-reflect",
"thin-foxes-lick",
"thirty-flowers-sit",
Expand All @@ -128,6 +144,8 @@
"wet-games-fly",
"wicked-clouds-exercise",
"wicked-doors-train",
"wild-foxes-wonder",
"wise-dancers-hang",
"wise-donkeys-marry",
"witty-camels-warn"
]
Expand Down
5 changes: 5 additions & 0 deletions .changeset/purple-dragons-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve unstate type definition
5 changes: 5 additions & 0 deletions .changeset/real-guests-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve event delegation handler hoisting
5 changes: 5 additions & 0 deletions .changeset/rotten-bags-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: correctly reflect readonly proxy marker
5 changes: 5 additions & 0 deletions .changeset/slow-chefs-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: improve each block fast-path heuristic
5 changes: 5 additions & 0 deletions .changeset/strong-gifts-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve html tag svg behaviour
5 changes: 5 additions & 0 deletions .changeset/tall-books-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure class constructor values are proxied
5 changes: 5 additions & 0 deletions .changeset/ten-peaches-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: better support for top-level snippet declarations
5 changes: 5 additions & 0 deletions .changeset/wild-foxes-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: cleanup each block animations on destroy
5 changes: 5 additions & 0 deletions .changeset/wise-dancers-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: improve each block index handling
52 changes: 52 additions & 0 deletions packages/svelte/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
# svelte

## 5.0.0-next.26

### Patch Changes

- fix: better handle array property deletion reactivity ([#9921](https://github.com/sveltejs/svelte/pull/9921))

- fix: improve event delegation handler hoisting ([#9929](https://github.com/sveltejs/svelte/pull/9929))

## 5.0.0-next.25

### Patch Changes

- fix: improve whitespace handling ([#9912](https://github.com/sveltejs/svelte/pull/9912))

- fix: improve each block fallback handling ([#9914](https://github.com/sveltejs/svelte/pull/9914))

- fix: cleanup each block animations on destroy ([#9917](https://github.com/sveltejs/svelte/pull/9917))

## 5.0.0-next.24

### Patch Changes

- fix: improve props aliasing ([#9900](https://github.com/sveltejs/svelte/pull/9900))

- feat: add support for `{@const}` inside snippet block ([#9904](https://github.com/sveltejs/svelte/pull/9904))

- fix: improve attribute directive reactivity detection ([#9907](https://github.com/sveltejs/svelte/pull/9907))

- fix: improve $inspect batching ([#9902](https://github.com/sveltejs/svelte/pull/9902))

- chore: improve readonly prop messaging ([#9901](https://github.com/sveltejs/svelte/pull/9901))

- fix: better support for top-level snippet declarations ([#9898](https://github.com/sveltejs/svelte/pull/9898))

## 5.0.0-next.23

### Patch Changes

- feat: add `gamepadconnected` and `gamepaddisconnected` events ([#9861](https://github.com/sveltejs/svelte/pull/9861))

- fix: improve unstate type definition ([#9895](https://github.com/sveltejs/svelte/pull/9895))

- fix: correctly reflect readonly proxy marker ([#9893](https://github.com/sveltejs/svelte/pull/9893))

- chore: improve each block fast-path heuristic ([#9855](https://github.com/sveltejs/svelte/pull/9855))

- fix: improve html tag svg behaviour ([#9894](https://github.com/sveltejs/svelte/pull/9894))

- fix: ensure class constructor values are proxied ([#9888](https://github.com/sveltejs/svelte/pull/9888))

- fix: improve each block index handling ([#9889](https://github.com/sveltejs/svelte/pull/9889))

## 5.0.0-next.22

### Patch Changes
Expand Down
7 changes: 7 additions & 0 deletions packages/svelte/elements.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type KeyboardEventHandler<T extends EventTarget> = EventHandler<KeyboardE
export type MouseEventHandler<T extends EventTarget> = EventHandler<MouseEvent, T>;
export type TouchEventHandler<T extends EventTarget> = EventHandler<TouchEvent, T>;
export type PointerEventHandler<T extends EventTarget> = EventHandler<PointerEvent, T>;
export type GamepadEventHandler<T extends EventTarget> = EventHandler<GamepadEvent, T>;
export type UIEventHandler<T extends EventTarget> = EventHandler<UIEvent, T>;
export type WheelEventHandler<T extends EventTarget> = EventHandler<WheelEvent, T>;
export type AnimationEventHandler<T extends EventTarget> = EventHandler<AnimationEvent, T>;
Expand Down Expand Up @@ -336,6 +337,12 @@ export interface DOMAttributes<T extends EventTarget> {
onlostpointercapture?: PointerEventHandler<T> | undefined | null;
onlostpointercapturecapture?: PointerEventHandler<T> | undefined | null;

// Gamepad Events
'on:gamepadconnected'?: GamepadEventHandler<T> | undefined | null;
ongamepadconnected?: GamepadEventHandler<T> | undefined | null;
'on:gamepaddisconnected'?: GamepadEventHandler<T> | undefined | null;
ongamepaddisconnected?: GamepadEventHandler<T> | undefined | null;

// UI Events
'on:scroll'?: UIEventHandler<T> | undefined | null;
onscroll?: UIEventHandler<T> | undefined | null;
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "svelte",
"description": "Cybernetically enhanced web apps",
"license": "MIT",
"version": "5.0.0-next.22",
"version": "5.0.0-next.26",
"type": "module",
"types": "./types/index.d.ts",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ const compiler_options = {
/** @satisfies {Errors} */
const const_tag = {
'invalid-const-placement': () =>
`{@const} must be the immediate child of {#if}, {:else if}, {:else}, {#each}, {:then}, {:catch}, <svelte:fragment> or <Component>`
`{@const} must be the immediate child of {#snippet}, {#if}, {:else if}, {:else}, {#each}, {:then}, {:catch}, <svelte:fragment> or <Component>`
};

/** @satisfies {Errors} */
Expand Down
14 changes: 14 additions & 0 deletions packages/svelte/src/compiler/phases/1-parse/utils/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ function validate_code(code) {

// based on http://developers.whatwg.org/syntax.html#syntax-tag-omission

const interactive_elements = new Set([
'a',
'button',
'iframe',
'embed',
'input',
'select',
'textarea'
]);

/** @type {Record<string, Set<string>>} */
const disallowed_contents = {
li: new Set(['li']),
Expand All @@ -143,6 +153,10 @@ const disallowed_contents = {
th: new Set(['td', 'th', 'tr'])
};

for (const interactive_element of interactive_elements) {
disallowed_contents[interactive_element] = interactive_elements;
}

// can this be a child of the parent element, or does it implicitly
// close it, like `<li>one<li>two`?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,7 @@ export default class Selector {
}

get_amount_class_specificity_increased() {
let count = 0;
for (const block of this.blocks) {
if (block.should_encapsulate) {
count++;
}
}
return count;
return this.blocks.filter((block) => block.should_encapsulate).length;
}
}

Expand Down
11 changes: 11 additions & 0 deletions packages/svelte/src/compiler/phases/2-analyze/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function get_delegated_event(node, context) {
return non_hoistable;
}

const visited_references = new Set();
const scope = target_function.metadata.scope;
for (const [reference] of scope.references) {
// Bail-out if the arguments keyword is used
Expand All @@ -174,6 +175,15 @@ function get_delegated_event(node, context) {
}
const binding = scope.get(reference);

// If we have multiple references to the same store using $ prefix, bail out.
if (
binding !== null &&
binding.kind === 'store_sub' &&
visited_references.has(reference.slice(1))
) {
return non_hoistable;
}

if (
binding !== null &&
// Bail-out if the the binding is a rest param
Expand All @@ -188,6 +198,7 @@ function get_delegated_event(node, context) {
) {
return non_hoistable;
}
visited_references.add(reference);
}
return { type: 'hoistable', function: target_function };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export const validation = {
grand_parent?.type !== 'SvelteComponent' &&
grand_parent?.type !== 'EachBlock' &&
grand_parent?.type !== 'AwaitBlock' &&
grand_parent?.type !== 'SnippetBlock' &&
((grand_parent?.type !== 'RegularElement' && grand_parent?.type !== 'SvelteElement') ||
!grand_parent.attributes.some((a) => a.type === 'Attribute' && a.name === 'slot')))
) {
Expand Down
Loading

0 comments on commit 35c3601

Please sign in to comment.