A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/vuejs/vue/commit/1933ee80ff808b81a691fa6a135c1588d218bc0a below:

Merges symbol provides (#7926) · vuejs/vue@1933ee8 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+34

-1

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+34

-1

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

@@ -4,6 +4,7 @@ import config from '../config'

4 4

import { warn } from './debug'

5 5

import { nativeWatch } from './env'

6 6

import { set } from '../observer/index'

7 +

import { hasSymbol } from '../util/index'

7 8 8 9

import {

9 10

ASSET_TYPES,

@@ -48,9 +49,15 @@ if (process.env.NODE_ENV !== 'production') {

48 49

function mergeData (to: Object, from: ?Object): Object {

49 50

if (!from) return to

50 51

let key, toVal, fromVal

51 -

const keys = Object.keys(from)

52 + 53 +

const keys = hasSymbol

54 +

? Reflect.ownKeys(from)

55 +

: Object.keys(from)

56 + 52 57

for (let i = 0; i < keys.length; i++) {

53 58

key = keys[i]

59 +

// in case the object is already observed...

60 +

if (key === '__ob__') continue

54 61

toVal = to[key]

55 62

fromVal = from[key]

56 63

if (!hasOwn(to, key)) {

Original file line number Diff line number Diff line change

@@ -188,6 +188,32 @@ describe('Options provide/inject', () => {

188 188

}).$mount()

189 189

expect(vm.$el.textContent).toBe('123')

190 190

})

191 + 192 +

it('should merge symbol provide from mixins (functions)', () => {

193 +

const keyA = Symbol('foo')

194 +

const keyB = Symbol('bar')

195 + 196 +

const mixinA = { provide: () => ({ [keyA]: 'foo' }) }

197 +

const mixinB = { provide: () => ({ [keyB]: 'bar' }) }

198 +

const child = {

199 +

inject: {

200 +

foo: keyA,

201 +

bar: keyB

202 +

},

203 +

template: `<span/>`,

204 +

created () {

205 +

injected = [this.foo, this.bar]

206 +

}

207 +

}

208 +

new Vue({

209 +

mixins: [mixinA, mixinB],

210 +

render (h) {

211 +

return h(child)

212 +

}

213 +

}).$mount()

214 + 215 +

expect(injected).toEqual(['foo', 'bar'])

216 +

})

191 217

}

192 218 193 219

// GitHub issue #5223

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