Skip to content

Commit

Permalink
Merge pull request #63 from sveltejs/master
Browse files Browse the repository at this point in the history
Sync Fork from Upstream Repo
  • Loading branch information
sthagen authored Feb 27, 2020
2 parents 11fae76 + 7831766 commit 351f8a1
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Svelte changelog

## Unreleased

* Exclude global variables from `$capture_state` ([#4463](https://github.com/sveltejs/svelte/issues/4463))

## 3.19.1

* Do not treat modifications to `$$props` as updates to a store called `$props` ([#4368](https://github.com/sveltejs/svelte/issues/4368))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import FancyButton from './FancyButton.svelte';
import CustomButton from './CustomButton.svelte';
function handleClick() {
alert('clicked');
}
</script>

<FancyButton on:click={handleClick}/>
<CustomButton on:click={handleClick}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<style>
button {
height: 4rem;
width: 8rem;
background-color: #aaa;
border-color: #f1c40f;
color: #f1c40f;
font-size: 1.25rem;
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
background-position: 100%;
background-size: 400%;
transition: background 300ms ease-in-out;
}
button:hover {
background-position: 0;
color: #aaa;
}
</style>

<button on:click>
Click me
</button>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import FancyButton from './FancyButton.svelte';
import CustomButton from './CustomButton.svelte';
function handleClick() {
alert('clicked');
}
</script>

<FancyButton on:click={handleClick}/>
<CustomButton on:click={handleClick}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<style>
button {
height: 4rem;
width: 8rem;
background-color: #aaa;
border-color: #f1c40f;
color: #f1c40f;
font-size: 1.25rem;
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
background-position: 100%;
background-size: 400%;
transition: background 300ms ease-in-out;
}
button:hover {
background-position: 0;
color: #aaa;
}
</style>

<button>
Click me
</button>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import FancyButton from './FancyButton.svelte';
import CustomButton from './CustomButton.svelte';
function handleClick() {
alert('clicked');
}
</script>

<FancyButton on:click={handleClick}/>
<CustomButton on:click={handleClick}/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<style>
button {
height: 4rem;
width: 8rem;
background-color: #aaa;
border-color: #f1c40f;
color: #f1c40f;
font-size: 1.25rem;
background-image: linear-gradient(45deg, #f1c40f 50%, transparent 50%);
background-position: 100%;
background-size: 400%;
transition: background 300ms ease-in-out;
}
button:hover {
background-position: 0;
color: #aaa;
}
</style>

<button on:click>
Click me
</button>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: DOM event forwarding

Event forwarding works for DOM events too.

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`:
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`:

```html
<button on:click>
Expand Down
Binary file modified site/static/examples/thumbnails/dom-event-forwarding.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/compiler/compile/render_dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default function dom(
`;
}

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

if (capturable_vars.length > 0) {
capture_state = x`() => ({ ${capturable_vars.map(prop => p`${prop.name}`)} })`;
Expand Down
8 changes: 4 additions & 4 deletions test/custom-elements/samples/extended-builtin/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ export default {
warnings: [{
code: "avoid-is",
message: "The 'is' attribute is not supported cross-browser and should be avoided",
pos: 97,
pos: 98,
start: {
character: 97,
character: 98,
column: 8,
line: 7
},
end: {
character: 114,
column: 25,
character: 116,
column: 26,
line: 7
}
}]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class CustomButton extends HTMLButtonElement {}
customElements.define('custom-button', CustomButton, { extends: 'button' });
2 changes: 0 additions & 2 deletions test/custom-elements/samples/extended-builtin/fancy-button.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/custom-elements/samples/extended-builtin/main.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<svelte:options tag="custom-element"/>

<script>
import './fancy-button.js';
import './custom-button.js';
</script>

<button is="fancy-button">click me</button>
<button is="custom-button">click me</button>
2 changes: 1 addition & 1 deletion test/custom-elements/samples/extended-builtin/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default function (target) {
const el = target.querySelector('custom-element');
const button = el.shadowRoot.querySelector('button');

assert.ok(button instanceof customElements.get('fancy-button'));
assert.ok(button instanceof customElements.get('custom-button'));
}
4 changes: 2 additions & 2 deletions test/js/samples/loop-protect/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function instance($$self, $$props, $$invalidate) {
});
}

$$self.$capture_state = () => ({ node, foo, console });
$$self.$capture_state = () => ({ node, foo });

$$self.$inject_state = $$props => {
if ("node" in $$props) $$invalidate(0, node = $$props.node);
Expand Down Expand Up @@ -153,4 +153,4 @@ class Component extends SvelteComponentDev {
}
}

export default Component;
export default Component;

0 comments on commit 351f8a1

Please sign in to comment.