Skip to content

Commit 1243c97

Browse files
committed
chore: change solution
chore: improve code chore: improve code
1 parent b0ce943 commit 1243c97

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

packages/runtime-core/src/component.ts

+9
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ export interface ComponentInternalInstance {
284284
*/
285285
emitsOptions: ObjectEmitsOptions | null
286286

287+
/**
288+
* resolved inheritAttrs options
289+
* @internal
290+
*/
291+
inheritAttrs?: boolean
292+
287293
// the rest are only for stateful components ---------------------------------
288294

289295
// main proxy that serves as the public instance (`this`)
@@ -464,6 +470,9 @@ export function createComponentInstance(
464470
// props default value
465471
propsDefaults: EMPTY_OBJ,
466472

473+
// inheritAttrs
474+
inheritAttrs: type.inheritAttrs,
475+
467476
// state
468477
ctx: EMPTY_OBJ,
469478
data: EMPTY_OBJ,

packages/runtime-core/src/componentOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ export function applyOptions(
755755
resolveInstanceAssets(instance, options, FILTERS)
756756
}
757757

758-
if (inheritAttrs !== undefined) instance.type.inheritAttrs = inheritAttrs
758+
if (inheritAttrs !== undefined) instance.inheritAttrs = inheritAttrs
759759
}
760760

761761
// lifecycle options

packages/runtime-core/src/componentRenderUtils.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export function renderComponentRoot(
5555
renderCache,
5656
data,
5757
setupState,
58-
ctx
58+
ctx,
59+
inheritAttrs
5960
} = instance
6061

6162
let result
@@ -123,7 +124,7 @@ export function renderComponentRoot(
123124
;[root, setRoot] = getChildRoot(result)
124125
}
125126

126-
if (fallthroughAttrs && Component.inheritAttrs !== false) {
127+
if (fallthroughAttrs && inheritAttrs !== false) {
127128
const keys = Object.keys(fallthroughAttrs)
128129
const { shapeFlag } = root
129130
if (keys.length) {
@@ -190,7 +191,7 @@ export function renderComponentRoot(
190191
) {
191192
const { class: cls, style } = vnode.props || {}
192193
if (cls || style) {
193-
if (__DEV__ && Component.inheritAttrs === false) {
194+
if (__DEV__ && inheritAttrs === false) {
194195
warnDeprecation(
195196
DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE,
196197
instance,

packages/server-renderer/src/render.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ function renderComponentSubTree(
128128
if (ssrRender) {
129129
// optimized
130130
// resolve fallthrough attrs
131-
let attrs =
132-
instance.type.inheritAttrs !== false ? instance.attrs : undefined
131+
let attrs = instance.inheritAttrs !== false ? instance.attrs : undefined
133132
let hasCloned = false
134133

135134
let cur = instance

0 commit comments

Comments
 (0)