Skip to content

Commit 2f9568c

Browse files
committed
turning warnings into errors
1 parent 59f2269 commit 2f9568c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/LiveComponent/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ code works identically to the previous example:
361361
</div>
362362
```
363363

364+
If an element has *both* `data-model` and `name` attributes, the
365+
`data-model` attribute takes precedence.
366+
364367
## Loading States
365368

366369
Often, you'll want to show (or hide) an element while a component is

src/LiveComponent/assets/src/set_deep_data.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ export function setDeepData(data, propertyPath, value) {
2525
}
2626

2727
// represents a situation where the key you're setting *is* an object,
28-
// but the key we're setting is a new key. This, perhaps, could be
29-
// allowed. But right now, all keys should be initialized with the
30-
// initial data.
28+
// but the key we're setting is a new key. Currently, all keys should
29+
// be initialized with the initial data.
3130
if (currentLevelData[finalKey] === undefined) {
3231
const lastPart = parts.pop();
3332
if (parts.length > 0) {
34-
console.warn(`The property used in data-model="${propertyPath}" was never initialized. Did you forget to add exposed={"${lastPart}"} to its LiveProp?`)
33+
throw new Error(`The property used in data-model="${propertyPath}" was never initialized. Did you forget to add exposed={"${lastPart}"} to its LiveProp?`)
3534
} else {
36-
console.warn(`The property used in data-model="${propertyPath}" was never initialized. Did you forget to expose "${lastPart}" as a LiveProp?`)
35+
throw new Error(`The property used in data-model="${propertyPath}" was never initialized. Did you forget to expose "${lastPart}" as a LiveProp? Available models values are: ${Object.keys(data).length > 0 ? Object.keys(data).join(', ') : '(none)'}`)
3736
}
3837
}
3938

0 commit comments

Comments
 (0)