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/51d2be20386d4dc59006d31a1cc96676871027ce below:

avoid deopt for props/emits normalization when global mixins ar… · vuejs/core@51d2be2 · GitHub

File tree Expand file treeCollapse file tree 5 files changed

+33

-26

lines changed

Filter options

Expand file treeCollapse file tree 5 files changed

+33

-26

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

@@ -20,6 +20,8 @@ import { devtoolsInitApp, devtoolsUnmountApp } from './devtools'

20 20

import { isFunction, NO, isObject } from '@vue/shared'

21 21

import { version } from '.'

22 22

import { installAppCompatProperties } from './compat/global'

23 +

import { NormalizedPropsOptions } from './componentProps'

24 +

import { ObjectEmitsOptions } from './componentEmits'

23 25 24 26

export interface App<HostElement = any> {

25 27

version: string

@@ -101,13 +103,19 @@ export interface AppContext {

101 103

* Cache for merged/normalized component options

102 104

* Each app instance has its own cache because app-level global mixins and

103 105

* optionMergeStrategies can affect merge behavior.

106 +

* @internal

104 107

*/

105 -

cache: WeakMap<ComponentOptions, MergedComponentOptions>

108 +

optionsCache: WeakMap<ComponentOptions, MergedComponentOptions>

106 109

/**

107 -

* Flag for de-optimizing props normalization

110 +

* Cache for normalized props options

108 111

* @internal

109 112

*/

110 -

deopt?: boolean

113 +

propsCache: WeakMap<ConcreteComponent, NormalizedPropsOptions>

114 +

/**

115 +

* Cache for normalized emits options

116 +

* @internal

117 +

*/

118 +

emitsCache: WeakMap<ConcreteComponent, ObjectEmitsOptions | null>

111 119

/**

112 120

* HMR only

113 121

* @internal

@@ -144,7 +152,9 @@ export function createAppContext(): AppContext {

144 152

components: {},

145 153

directives: {},

146 154

provides: Object.create(null),

147 -

cache: new WeakMap()

155 +

optionsCache: new WeakMap(),

156 +

propsCache: new WeakMap(),

157 +

emitsCache: new WeakMap()

148 158

}

149 159

}

150 160

@@ -213,11 +223,6 @@ export function createAppAPI<HostElement>(

213 223

if (__FEATURE_OPTIONS_API__) {

214 224

if (!context.mixins.includes(mixin)) {

215 225

context.mixins.push(mixin)

216 -

// global mixin with props/emits de-optimizes props/emits

217 -

// normalization caching.

218 -

if (mixin.props || mixin.emits) {

219 -

context.deopt = true

220 -

}

221 226

} else if (__DEV__) {

222 227

warn(

223 228

'Mixin has already been applied to target app' +

Original file line number Diff line number Diff line change

@@ -76,14 +76,6 @@ export interface AllowedComponentProps {

76 76

// Note: can't mark this whole interface internal because some public interfaces

77 77

// extend it.

78 78

export interface ComponentInternalOptions {

79 -

/**

80 -

* @internal

81 -

*/

82 -

__props?: NormalizedPropsOptions

83 -

/**

84 -

* @internal

85 -

*/

86 -

__emits?: ObjectEmitsOptions | null

87 79

/**

88 80

* @internal

89 81

*/

Original file line number Diff line number Diff line change

@@ -172,8 +172,10 @@ export function normalizeEmitsOptions(

172 172

appContext: AppContext,

173 173

asMixin = false

174 174

): ObjectEmitsOptions | null {

175 -

if (!appContext.deopt && comp.__emits !== undefined) {

176 -

return comp.__emits

175 +

const cache = appContext.emitsCache

176 +

const cached = cache.get(comp)

177 +

if (cached !== undefined) {

178 +

return cached

177 179

}

178 180 179 181

const raw = comp.emits

@@ -201,15 +203,18 @@ export function normalizeEmitsOptions(

201 203

}

202 204 203 205

if (!raw && !hasExtends) {

204 -

return (comp.__emits = null)

206 +

cache.set(comp, null)

207 +

return null

205 208

}

206 209 207 210

if (isArray(raw)) {

208 211

raw.forEach(key => (normalized[key] = null))

209 212

} else {

210 213

extend(normalized, raw)

211 214

}

212 -

return (comp.__emits = normalized)

215 + 216 +

cache.set(comp, normalized)

217 +

return normalized

213 218

}

214 219 215 220

// Check if an incoming prop key is a declared emit event listener.

Original file line number Diff line number Diff line change

@@ -894,7 +894,7 @@ export function resolveMergedOptions(

894 894

const { mixins, extends: extendsOptions } = base

895 895

const {

896 896

mixins: globalMixins,

897 -

cache,

897 +

optionsCache: cache,

898 898

config: { optionMergeStrategies }

899 899

} = instance.appContext

900 900

const cached = cache.get(base)

Original file line number Diff line number Diff line change

@@ -436,8 +436,10 @@ export function normalizePropsOptions(

436 436

appContext: AppContext,

437 437

asMixin = false

438 438

): NormalizedPropsOptions {

439 -

if (!appContext.deopt && comp.__props) {

440 -

return comp.__props

439 +

const cache = appContext.propsCache

440 +

const cached = cache.get(comp)

441 +

if (cached) {

442 +

return cached

441 443

}

442 444 443 445

const raw = comp.props

@@ -468,7 +470,8 @@ export function normalizePropsOptions(

468 470

}

469 471 470 472

if (!raw && !hasExtends) {

471 -

return (comp.__props = EMPTY_ARR as any)

473 +

cache.set(comp, EMPTY_ARR as any)

474 +

return EMPTY_ARR as any

472 475

}

473 476 474 477

if (isArray(raw)) {

@@ -506,7 +509,9 @@ export function normalizePropsOptions(

506 509

}

507 510

}

508 511 509 -

return (comp.__props = [normalized, needCastKeys])

512 +

const res: NormalizedPropsOptions = [normalized, needCastKeys]

513 +

cache.set(comp, res)

514 +

return res

510 515

}

511 516 512 517

function validatePropName(key: string) {

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