Skip to content

Commit 351f8a1

Browse files
authored
Merge pull request #63 from sveltejs/master
Sync Fork from Upstream Repo
2 parents 11fae76 + 7831766 commit 351f8a1

File tree

19 files changed

+89
-64
lines changed

19 files changed

+89
-64
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Svelte changelog
22

3+
## Unreleased
4+
5+
* Exclude global variables from `$capture_state` ([#4463](https://github.com/sveltejs/svelte/issues/4463))
6+
37
## 3.19.1
48

59
* Do not treat modifications to `$$props` as updates to a store called `$props` ([#4368](https://github.com/sveltejs/svelte/issues/4368))
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script>
2-
import FancyButton from './FancyButton.svelte';
2+
import CustomButton from './CustomButton.svelte';
33
44
function handleClick() {
55
alert('clicked');
66
}
77
</script>
88

9-
<FancyButton on:click={handleClick}/>
9+
<CustomButton on:click={handleClick}/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<style>
2+
button {
3+
height: 4rem;
4+
width: 8rem;
5+
background-color: #aaa;
6+
border-color: #f1c40f;
7+
color: #f1c40f;
8+
font-size: 1.25rem;
9+
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
10+
background-position: 100%;
11+
background-size: 400%;
12+
transition: background 300ms ease-in-out;
13+
}
14+
button:hover {
15+
background-position: 0;
16+
color: #aaa;
17+
}
18+
</style>
19+
20+
<button on:click>
21+
Click me
22+
</button>

site/content/examples/04-events/05-dom-event-forwarding/FancyButton.svelte

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script>
2-
import FancyButton from './FancyButton.svelte';
2+
import CustomButton from './CustomButton.svelte';
33
44
function handleClick() {
55
alert('clicked');
66
}
77
</script>
88

9-
<FancyButton on:click={handleClick}/>
9+
<CustomButton on:click={handleClick}/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<style>
2+
button {
3+
height: 4rem;
4+
width: 8rem;
5+
background-color: #aaa;
6+
border-color: #f1c40f;
7+
color: #f1c40f;
8+
font-size: 1.25rem;
9+
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
10+
background-position: 100%;
11+
background-size: 400%;
12+
transition: background 300ms ease-in-out;
13+
}
14+
button:hover {
15+
background-position: 0;
16+
color: #aaa;
17+
}
18+
</style>
19+
20+
<button>
21+
Click me
22+
</button>

site/content/tutorial/05-events/06-dom-event-forwarding/app-a/FancyButton.svelte

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script>
2-
import FancyButton from './FancyButton.svelte';
2+
import CustomButton from './CustomButton.svelte';
33
44
function handleClick() {
55
alert('clicked');
66
}
77
</script>
88

9-
<FancyButton on:click={handleClick}/>
9+
<CustomButton on:click={handleClick}/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<style>
2+
button {
3+
height: 4rem;
4+
width: 8rem;
5+
background-color: #aaa;
6+
border-color: #f1c40f;
7+
color: #f1c40f;
8+
font-size: 1.25rem;
9+
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
10+
background-position: 100%;
11+
background-size: 400%;
12+
transition: background 300ms ease-in-out;
13+
}
14+
button:hover {
15+
background-position: 0;
16+
color: #aaa;
17+
}
18+
</style>
19+
20+
<button on:click>
21+
Click me
22+
</button>

site/content/tutorial/05-events/06-dom-event-forwarding/app-b/FancyButton.svelte

-15
This file was deleted.

site/content/tutorial/05-events/06-dom-event-forwarding/text.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: DOM event forwarding
44

55
Event forwarding works for DOM events too.
66

7-
We want to get notified of clicks on our `<FancyButton>` — to do that, we just need to forward `click` events on the `<button>` element in `FancyButton.svelte`:
7+
We want to get notified of clicks on our `<CustomButton>` — to do that, we just need to forward `click` events on the `<button>` element in `CustomButton.svelte`:
88

99
```html
1010
<button on:click>
Loading

src/compiler/compile/render_dom/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default function dom(
167167
`;
168168
}
169169

170-
const capturable_vars = component.vars.filter(v => !v.internal && !v.name.startsWith('$$'));
170+
const capturable_vars = component.vars.filter(v => !v.internal && !v.global && !v.name.startsWith('$$'));
171171

172172
if (capturable_vars.length > 0) {
173173
capture_state = x`() => ({ ${capturable_vars.map(prop => p`${prop.name}`)} })`;

test/custom-elements/samples/extended-builtin/_config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ export default {
22
warnings: [{
33
code: "avoid-is",
44
message: "The 'is' attribute is not supported cross-browser and should be avoided",
5-
pos: 97,
5+
pos: 98,
66
start: {
7-
character: 97,
7+
character: 98,
88
column: 8,
99
line: 7
1010
},
1111
end: {
12-
character: 114,
13-
column: 25,
12+
character: 116,
13+
column: 26,
1414
line: 7
1515
}
1616
}]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class CustomButton extends HTMLButtonElement {}
2+
customElements.define('custom-button', CustomButton, { extends: 'button' });

test/custom-elements/samples/extended-builtin/fancy-button.js

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<svelte:options tag="custom-element"/>
22

33
<script>
4-
import './fancy-button.js';
4+
import './custom-button.js';
55
</script>
66

7-
<button is="fancy-button">click me</button>
7+
<button is="custom-button">click me</button>

test/custom-elements/samples/extended-builtin/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export default function (target) {
1111
const el = target.querySelector('custom-element');
1212
const button = el.shadowRoot.querySelector('button');
1313

14-
assert.ok(button instanceof customElements.get('fancy-button'));
14+
assert.ok(button instanceof customElements.get('custom-button'));
1515
}

test/js/samples/loop-protect/expected.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function instance($$self, $$props, $$invalidate) {
108108
});
109109
}
110110

111-
$$self.$capture_state = () => ({ node, foo, console });
111+
$$self.$capture_state = () => ({ node, foo });
112112

113113
$$self.$inject_state = $$props => {
114114
if ("node" in $$props) $$invalidate(0, node = $$props.node);
@@ -153,4 +153,4 @@ class Component extends SvelteComponentDev {
153153
}
154154
}
155155

156-
export default Component;
156+
export default Component;

0 commit comments

Comments
 (0)