mirror of https://github.com/sveltejs/svelte
parent
44a7813730
commit
60c724945a
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: preserve short-circuiting for logical assignments to private state fields
|
||||
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<p>truthy||value</p>`
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
class Values {
|
||||
#or = $state.raw('truthy');
|
||||
#and = $state.raw('');
|
||||
#nullish = $state.raw('value');
|
||||
|
||||
get or() {
|
||||
return (this.#or ||= 'assigned');
|
||||
}
|
||||
|
||||
get and() {
|
||||
return (this.#and &&= 'assigned');
|
||||
}
|
||||
|
||||
get nullish() {
|
||||
return (this.#nullish ??= 'assigned');
|
||||
}
|
||||
}
|
||||
|
||||
const values = new Values();
|
||||
const result = $derived([values.or, values.and, values.nullish]);
|
||||
</script>
|
||||
|
||||
<p>{result.join('|')}</p>
|
||||
Loading…
Reference in new issue