forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
509a7bd
commit 38cb5b9
Showing
5 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/runtime/samples/dynamic-element-attribute-boolean/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
props: { | ||
disabled: false | ||
}, | ||
html: '<button>Click me</button>', | ||
|
||
test({ assert, component, target }) { | ||
const button = target.querySelector('button'); | ||
assert.equal(button.disabled, false); | ||
|
||
component.disabled = true; | ||
assert.htmlEqual(target.innerHTML, '<button disabled>Click me</button>'); | ||
assert.equal(button.disabled, true); | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/runtime/samples/dynamic-element-attribute-boolean/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let disabled = false; | ||
</script> | ||
|
||
<svelte:element {disabled} this="button">Click me</svelte:element> |
23 changes: 23 additions & 0 deletions
23
test/runtime/samples/dynamic-element-attribute-spread/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export default { | ||
props: { | ||
props: { | ||
disabled: true, | ||
type: 'button', | ||
'data-named': 'foo' | ||
} | ||
}, | ||
html: '<button disabled type="button" data-named="foo">Click me</button>', | ||
|
||
test({ assert, component, target }) { | ||
const button = target.querySelector('button'); | ||
assert.equal(button.disabled, true); | ||
assert.equal(button.type, 'button'); | ||
assert.equal(button.dataset.named, 'foo'); | ||
|
||
component.props = { type: 'submit' }; | ||
assert.htmlEqual(target.innerHTML, '<button type="submit">Click me</button>'); | ||
assert.equal(button.disabled, false); | ||
assert.equal(button.type, 'submit'); | ||
assert.equal(button.dataset.named, undefined); | ||
} | ||
}; |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/dynamic-element-attribute-spread/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script> | ||
export let props = { | ||
disabled: false, | ||
type: 'button', | ||
'data-named': 'foo' | ||
}; | ||
</script> | ||
|
||
<svelte:element this="button" {...props}>Click me</svelte:element> |