fix(v-model): allow v-model usage on declared custom elements
fix #1699
This commit is contained in:
@@ -1,5 +1,21 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`compiler: transform v-model errors should allow custom element 1`] = `
|
||||
"const _Vue = Vue
|
||||
|
||||
return function render(_ctx, _cache) {
|
||||
with (_ctx) {
|
||||
const { vModelText: _vModelText, createVNode: _createVNode, withDirectives: _withDirectives, openBlock: _openBlock, createBlock: _createBlock } = _Vue
|
||||
|
||||
return _withDirectives((_openBlock(), _createBlock(\\"my-input\\", {
|
||||
\\"onUpdate:modelValue\\": $event => (model = $event)
|
||||
}, null, 8 /* PROPS */, [\\"onUpdate:modelValue\\"])), [
|
||||
[_vModelText, model]
|
||||
])
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`compiler: transform v-model input w/ dynamic v-bind 1`] = `
|
||||
"const _Vue = Vue
|
||||
|
||||
|
||||
@@ -115,6 +115,17 @@ describe('compiler: transform v-model', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('should allow usage on custom element', () => {
|
||||
const onError = jest.fn()
|
||||
const root = transformWithModel('<my-input v-model="model" />', {
|
||||
onError,
|
||||
isCustomElement: tag => tag.startsWith('my-')
|
||||
})
|
||||
expect(root.helpers).toContain(V_MODEL_TEXT)
|
||||
expect(onError).not.toHaveBeenCalled()
|
||||
expect(generate(root).code).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('should raise error if used file input element', () => {
|
||||
const onError = jest.fn()
|
||||
transformWithModel(`<input type="file" v-model="test"/>`, {
|
||||
|
||||
Reference in New Issue
Block a user