diff --git a/src/picker/components/Picker/framework.js b/src/picker/components/Picker/framework.js index 6d08c231..15c2030d 100644 --- a/src/picker/components/Picker/framework.js +++ b/src/picker/components/Picker/framework.js @@ -79,6 +79,10 @@ function patch (expressions, instanceBindings) { const expression = expressions[expressionIndex] + if (import.meta.env.MODE !== 'production' && expression === undefined && (attributeValuePre || attributeValuePost)) { + throw new Error('framework does not support undefined expressions with attribute pre/post') + } + if (currentExpression === expression) { // no need to update, same as before continue diff --git a/test/spec/picker/framework.test.js b/test/spec/picker/framework.test.js index 0f4fc160..b4e1f57c 100644 --- a/test/spec/picker/framework.test.js +++ b/test/spec/picker/framework.test.js @@ -118,26 +118,18 @@ describe('framework', () => { expect(node.getAttribute('aria-selected')).toBe(null) }) - test('set to undefined then something then back to undefined - with pre/post text', () => { + test('set to undefined - with pre/post text', () => { const state = { value: undefined } const { html } = createFramework(state) - let node - const render = () => { - node = html`
` + const renders = [ + () => html``, + () => html``, + () => html`` + ] + for (const render of renders) { + expect(render).toThrow(/framework does not support undefined expressions with attribute pre\/post/) } - - render() - // expect(node.getAttribute('class')).toBe('foo undefined bar') - expect(node.getAttribute('class')).toBe(null) // we don't handle the initial undefined case correctly - - state.value = true - render() - expect(node.getAttribute('class')).toBe('foo true bar') - - state.value = undefined - render() - expect(node.getAttribute('class')).toBe('foo undefined bar') }) // Framework no longer supports this since we switched from HTML comments to text nodes