mirror of https://github.com/sveltejs/svelte
fix: set strings as attributes, non-strings as properties if property exists (#13327)
* fix: set strings as attributes, non-strings as properties if property exists * simplify * remove draggable from list, no longer needed * in fact we dont need the lookup at all * lint * beef up test * correctly SSR translate attributepull/13336/head
parent
2553932c2c
commit
b3f3915180
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: set strings as attributes, non-strings as properties if property exists
|
@ -0,0 +1,24 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, target, variant, hydrate }) {
|
||||||
|
function check(/** @type {boolean} */ condition) {
|
||||||
|
const divs = /** @type {NodeListOf<HTMLDivElement>} */ (
|
||||||
|
target.querySelectorAll(`.translate-${condition} div`)
|
||||||
|
);
|
||||||
|
|
||||||
|
divs.forEach((div, i) => {
|
||||||
|
assert.equal(div.translate, condition, `${i + 1} of ${divs.length}: ${div.outerHTML}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
check(false);
|
||||||
|
check(true);
|
||||||
|
|
||||||
|
if (variant === 'hydrate') {
|
||||||
|
hydrate();
|
||||||
|
check(false);
|
||||||
|
check(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,19 @@
|
|||||||
|
<div class="translate-false">
|
||||||
|
<div translate={false}></div>
|
||||||
|
<div translate="no"></div>
|
||||||
|
<div {...{ translate: false }}></div>
|
||||||
|
<div {...{ translate: 'no' }}></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="translate-true">
|
||||||
|
<div></div>
|
||||||
|
<div translate={true}></div>
|
||||||
|
<div translate="yes"></div>
|
||||||
|
<div {...{ translate: true }}></div>
|
||||||
|
<div {...{ translate: 'yes' }}></div>
|
||||||
|
|
||||||
|
<div translate="false"></div>
|
||||||
|
<div translate="banana"></div>
|
||||||
|
<div {...{ translate: 'false' }}></div>
|
||||||
|
<div {...{ translate: 'banana' }}></div>
|
||||||
|
</div>
|
Loading…
Reference in new issue