A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/vuejs/vue-next/commit/d6607c9864376fbe17899f3d35fc7b097670a1b1 below:

fix resolving inheritAttrs from mixins (#3742) · vuejs/core@d6607c9 · GitHub

File tree Expand file treeCollapse file tree 5 files changed

+65

-21

lines changed

Filter options

Expand file treeCollapse file tree 5 files changed

+65

-21

lines changed Original file line number Diff line number Diff line change

@@ -301,6 +301,34 @@ describe('attribute fallthrough', () => {

301 301

expect(root.innerHTML).toMatch(`<div>1</div>`)

302 302

})

303 303 304 +

// #3741

305 +

it('should not fallthrough with inheritAttrs: false from mixins', () => {

306 +

const Parent = {

307 +

render() {

308 +

return h(Child, { foo: 1, class: 'parent' })

309 +

}

310 +

}

311 + 312 +

const mixin = {

313 +

inheritAttrs: false

314 +

}

315 + 316 +

const Child = defineComponent({

317 +

mixins: [mixin],

318 +

props: ['foo'],

319 +

render() {

320 +

return h('div', this.foo)

321 +

}

322 +

})

323 + 324 +

const root = document.createElement('div')

325 +

document.body.appendChild(root)

326 +

render(h(Parent), root)

327 + 328 +

// should not contain class

329 +

expect(root.innerHTML).toMatch(`<div>1</div>`)

330 +

})

331 + 304 332

it('explicit spreading with inheritAttrs: false', () => {

305 333

const Parent = {

306 334

render() {

Original file line number Diff line number Diff line change

@@ -285,6 +285,12 @@ export interface ComponentInternalInstance {

285 285

*/

286 286

emitsOptions: ObjectEmitsOptions | null

287 287 288 +

/**

289 +

* resolved inheritAttrs options

290 +

* @internal

291 +

*/

292 +

inheritAttrs?: boolean

293 + 288 294

// the rest are only for stateful components ---------------------------------

289 295 290 296

// main proxy that serves as the public instance (`this`)

@@ -469,6 +475,9 @@ export function createComponentInstance(

469 475

// props default value

470 476

propsDefaults: EMPTY_OBJ,

471 477 478 +

// inheritAttrs

479 +

inheritAttrs: type.inheritAttrs,

480 + 472 481

// state

473 482

ctx: EMPTY_OBJ,

474 483

data: EMPTY_OBJ,

Original file line number Diff line number Diff line change

@@ -567,17 +567,14 @@ export function applyOptions(

567 567

errorCaptured,

568 568

serverPrefetch,

569 569

// public API

570 -

expose

570 +

expose,

571 +

inheritAttrs

571 572

} = options

572 573 573 574

const publicThis = instance.proxy!

574 575

const ctx = instance.ctx

575 576

const globalMixins = instance.appContext.mixins

576 577 577 -

if (asMixin && render && instance.render === NOOP) {

578 -

instance.render = render as InternalRenderFunction

579 -

}

580 - 581 578

// applyOptions is called non-as-mixin once per instance

582 579

if (!asMixin) {

583 580

shouldCacheAccess = false

@@ -755,17 +752,6 @@ export function applyOptions(

755 752

})

756 753

}

757 754 758 -

// asset options.

759 -

// To reduce memory usage, only components with mixins or extends will have

760 -

// resolved asset registry attached to instance.

761 -

if (asMixin) {

762 -

resolveInstanceAssets(instance, options, COMPONENTS)

763 -

resolveInstanceAssets(instance, options, DIRECTIVES)

764 -

if (__COMPAT__ && isCompatEnabled(DeprecationTypes.FILTERS, instance)) {

765 -

resolveInstanceAssets(instance, options, FILTERS)

766 -

}

767 -

}

768 - 769 755

// lifecycle options

770 756

if (!asMixin) {

771 757

callSyncHook(

@@ -831,6 +817,27 @@ export function applyOptions(

831 817

warn(`The \`expose\` option is ignored when used in mixins.`)

832 818

}

833 819

}

820 + 821 +

// options that are handled when creating the instance but also need to be

822 +

// applied from mixins

823 +

if (asMixin) {

824 +

if (render && instance.render === NOOP) {

825 +

instance.render = render as InternalRenderFunction

826 +

}

827 + 828 +

if (inheritAttrs != null && instance.type.inheritAttrs == null) {

829 +

instance.inheritAttrs = inheritAttrs

830 +

}

831 + 832 +

// asset options.

833 +

// To reduce memory usage, only components with mixins or extends will have

834 +

// resolved asset registry attached to instance.

835 +

resolveInstanceAssets(instance, options, COMPONENTS)

836 +

resolveInstanceAssets(instance, options, DIRECTIVES)

837 +

if (__COMPAT__ && isCompatEnabled(DeprecationTypes.FILTERS, instance)) {

838 +

resolveInstanceAssets(instance, options, FILTERS)

839 +

}

840 +

}

834 841

}

835 842 836 843

function resolveInstanceAssets(

Original file line number Diff line number Diff line change

@@ -55,7 +55,8 @@ export function renderComponentRoot(

55 55

renderCache,

56 56

data,

57 57

setupState,

58 -

ctx

58 +

ctx,

59 +

inheritAttrs

59 60

} = instance

60 61 61 62

let result

@@ -123,7 +124,7 @@ export function renderComponentRoot(

123 124

;[root, setRoot] = getChildRoot(result)

124 125

}

125 126 126 -

if (fallthroughAttrs && Component.inheritAttrs !== false) {

127 +

if (fallthroughAttrs && inheritAttrs !== false) {

127 128

const keys = Object.keys(fallthroughAttrs)

128 129

const { shapeFlag } = root

129 130

if (keys.length) {

@@ -190,7 +191,7 @@ export function renderComponentRoot(

190 191

) {

191 192

const { class: cls, style } = vnode.props || {}

192 193

if (cls || style) {

193 -

if (__DEV__ && Component.inheritAttrs === false) {

194 +

if (__DEV__ && inheritAttrs === false) {

194 195

warnDeprecation(

195 196

DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE,

196 197

instance,

Original file line number Diff line number Diff line change

@@ -132,8 +132,7 @@ function renderComponentSubTree(

132 132

if (ssrRender) {

133 133

// optimized

134 134

// resolve fallthrough attrs

135 -

let attrs =

136 -

instance.type.inheritAttrs !== false ? instance.attrs : undefined

135 +

let attrs = instance.inheritAttrs !== false ? instance.attrs : undefined

137 136

let hasCloned = false

138 137 139 138

let cur = instance

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4