Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(customElement): should properly patch as props for vue custom elements #12409

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/runtime-dom/__tests__/customElement.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,14 @@ describe('defineCustomElement', () => {
container.appendChild(e)
expect(e.shadowRoot!.innerHTML).toBe('<div></div>')
})

// #12408
test('should set number tabindex as attribute', () => {
render(h('my-el-attrs', { tabindex: 1, 'data-test': true }), container)
const el = container.children[0] as HTMLElement
expect(el.getAttribute('tabindex')).toBe('1')
expect(el.getAttribute('data-test')).toBe('true')
})
})

describe('emits', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
} else if (
// #11081 force set props for possible async custom element
(el as VueElement)._isVueCE &&
(/[A-Z]/.test(key) || !isString(nextValue))
// #12408 check if it's hyphen prop or it's async custom element
(camelize(key) in el ||
// @ts-expect-error _def is private
((el as VueElement)._def.__asyncLoader &&
edison1105 marked this conversation as resolved.
Show resolved Hide resolved
(/[A-Z]/.test(key) || !isString(nextValue))))
) {
patchDOMProp(el, camelize(key), nextValue, parentComponent, key)
} else {
Expand Down