A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/vuejs/vue/commit/51c595a below:

support Array for include and exclude (#5956) · vuejs/vue@51c595a · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+43

-5

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+43

-5

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

@@ -5,14 +5,16 @@ import { getFirstComponentChild } from 'core/vdom/helpers/index'

5 5 6 6

type VNodeCache = { [key: string]: ?VNode };

7 7 8 -

const patternTypes: Array<Function> = [String, RegExp]

8 +

const patternTypes: Array<Function> = [String, RegExp, Array]

9 9 10 10

function getComponentName (opts: ?VNodeComponentOptions): ?string {

11 11

return opts && (opts.Ctor.options.name || opts.tag)

12 12

}

13 13 14 -

function matches (pattern: string | RegExp, name: string): boolean {

15 -

if (typeof pattern === 'string') {

14 +

function matches (pattern: string | RegExp | Array<string>, name: string): boolean {

15 +

if (Array.isArray(pattern)) {

16 +

return pattern.indexOf(name) > -1

17 +

} else if (typeof pattern === 'string') {

16 18

return pattern.split(',').indexOf(name) > -1

17 19

} else if (isRegExp(pattern)) {

18 20

return pattern.test(name)

@@ -62,10 +64,10 @@ export default {

62 64

},

63 65 64 66

watch: {

65 -

include (val: string | RegExp) {

67 +

include (val: string | RegExp | Array<string>) {

66 68

pruneCache(this.cache, this._vnode, name => matches(val, name))

67 69

},

68 -

exclude (val: string | RegExp) {

70 +

exclude (val: string | RegExp | Array<string>) {

69 71

pruneCache(this.cache, this._vnode, name => !matches(val, name))

70 72

}

71 73

},

Original file line number Diff line number Diff line change

@@ -272,6 +272,24 @@ describe('Component keep-alive', () => {

272 272

sharedAssertions(vm, done)

273 273

})

274 274 275 +

it('include (array)', done => {

276 +

const vm = new Vue({

277 +

template: `

278 +

<div v-if="ok">

279 +

<keep-alive :include="['one']">

280 +

<component :is="view"></component>

281 +

</keep-alive>

282 +

</div>

283 +

`,

284 +

data: {

285 +

view: 'one',

286 +

ok: true

287 +

},

288 +

components

289 +

}).$mount()

290 +

sharedAssertions(vm, done)

291 +

})

292 + 275 293

it('exclude (string)', done => {

276 294

const vm = new Vue({

277 295

template: `

@@ -308,6 +326,24 @@ describe('Component keep-alive', () => {

308 326

sharedAssertions(vm, done)

309 327

})

310 328 329 +

it('exclude (array)', done => {

330 +

const vm = new Vue({

331 +

template: `

332 +

<div v-if="ok">

333 +

<keep-alive :exclude="['two']">

334 +

<component :is="view"></component>

335 +

</keep-alive>

336 +

</div>

337 +

`,

338 +

data: {

339 +

view: 'one',

340 +

ok: true

341 +

},

342 +

components

343 +

}).$mount()

344 +

sharedAssertions(vm, done)

345 +

})

346 + 311 347

it('include + exclude', done => {

312 348

const vm = new Vue({

313 349

template: `

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