Skip to content

Commit

Permalink
test(ssr): assert read-only-props for lwc:is (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Nov 25, 2024
1 parent 4aa7768 commit 3aaf2f2
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<x-parent>
<template shadowrootmode="open">
<x-child>
<template shadowrootmode="open">
<div>

array: error hit during mutation
object: error hit during mutation
deep: error hit during mutation
object: error hit during deletion
</div>
</template>
</x-child>
</template>
</x-parent>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { LightningElement, api } from "lwc";

export default class extends LightningElement {
@api array
@api object
@api deep

result

connectedCallback() {
const results = []

try {
this.array.push('bar')
} catch (err) {
results.push('array: error hit during mutation')
}

try {
this.object.foo = 'baz'
} catch (err) {
results.push('object: error hit during mutation')
}

try {
this.deep.foo[0].quux = 'quux'
} catch (err) {
results.push('deep: error hit during mutation')
}

try {
delete this.object.foo
} catch (err) {
results.push('object: error hit during deletion')
}

this.result = '\n' + results.join('\n')
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<template>
<lwc:component lwc:is={ctor}
array={array}
object={object}
deep={deep}
>
</lwc:component>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { LightningElement } from "lwc";
import Child from 'x/child'

export default class extends LightningElement {
ctor = Child
array = [1, 2, 3]
object = { foo: 'bar '}
deep = { foo: [{ bar: 'baz' }]}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const tagName = 'x-parent';
export { default } from 'x/parent';
export * from 'x/parent';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>{result}</div>
</template>

0 comments on commit 3aaf2f2

Please sign in to comment.