-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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): handle hyphenated prop pass to custom element #12032
Changes from 4 commits
c930666
dc66355
3372be6
95c9869
74bd014
e5dbce5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { DeprecationTypes, compatUtils, warn } from '@vue/runtime-core' | ||
import { includeBooleanAttr } from '@vue/shared' | ||
import { camelize, includeBooleanAttr } from '@vue/shared' | ||
import { unsafeToTrustedHTML } from '../nodeOps' | ||
|
||
// functions. The user is responsible for using them with only trusted content. | ||
|
@@ -95,7 +95,7 @@ export function patchDOMProp( | |
// some properties has getter, no setter, will error in 'use strict' | ||
// eg. <select :type="null"></select> <select :willValidate="null"></select> | ||
try { | ||
el[key] = value | ||
el[camelize(key)] = value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't do it here as it affects all elements. This should only apply to Vue custom elements. See ea3efa0 (reused test from this PR) |
||
} catch (e: any) { | ||
// do not warn if value is auto-coerced from nullish values | ||
if (__DEV__ && !needRemove) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,13 @@ import { patchStyle } from './modules/style' | |
import { patchAttr } from './modules/attrs' | ||
import { patchDOMProp } from './modules/props' | ||
import { patchEvent } from './modules/events' | ||
import { isFunction, isModelListener, isOn, isString } from '@vue/shared' | ||
import { | ||
camelize, | ||
isFunction, | ||
isModelListener, | ||
isOn, | ||
isString, | ||
} from '@vue/shared' | ||
import type { RendererOptions } from '@vue/runtime-core' | ||
import type { VueElement } from './apiCustomElement' | ||
|
||
|
@@ -127,8 +133,8 @@ function shouldSetAsProp( | |
if (isNativeOn(key) && isString(value)) { | ||
return false | ||
} | ||
|
||
if (key in el) { | ||
// if el is a Vue custom element, it should be passed as a prop. | ||
if (camelize(key) in el) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change is unnecessary. see line 142 |
||
return true | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the proper change. because the normalized prop key is always camelized