mirror of https://github.com/sveltejs/svelte
[fix] always use `set_attributes` for attribute of `<svelte:element>` (#7486)
parent
a28e7392c0
commit
1f1750e72e
@ -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);
|
||||
}
|
||||
};
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
export let disabled = false;
|
||||
</script>
|
||||
|
||||
<svelte:element {disabled} this="button">Click me</svelte:element>
|
@ -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);
|
||||
}
|
||||
};
|
@ -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>
|
Loading…
Reference in new issue