1
1
/**
2
- * vue-meta v2.3.0
2
+ * vue-meta v2.3.1
3
3
* (c) 2019
4
4
* - Declan de Wet
5
5
* - Sébastien Chopin (@Atinux)
@@ -14,7 +14,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
14
14
15
15
var deepmerge = _interopDefault ( require ( 'deepmerge' ) ) ;
16
16
17
- var version = "2.3.0 " ;
17
+ var version = "2.3.1 " ;
18
18
19
19
function _typeof ( obj ) {
20
20
if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) {
@@ -233,6 +233,63 @@ function batchUpdate(callback, timeout) {
233
233
return batchId ;
234
234
}
235
235
236
+ /*
237
+ * To reduce build size, this file provides simple polyfills without
238
+ * overly excessive type checking and without modifying
239
+ * the global Array.prototype
240
+ * The polyfills are automatically removed in the commonjs build
241
+ * Also, only files in client/ & shared/ should use these functions
242
+ * files in server/ still use normal js function
243
+ */
244
+ function find ( array , predicate , thisArg ) {
245
+ if ( ! Array . prototype . find ) {
246
+ // idx needs to be a Number, for..in returns string
247
+ for ( var idx = 0 ; idx < array . length ; idx ++ ) {
248
+ if ( predicate . call ( thisArg , array [ idx ] , idx , array ) ) {
249
+ return array [ idx ] ;
250
+ }
251
+ }
252
+
253
+ return ;
254
+ }
255
+
256
+ return array . find ( predicate , thisArg ) ;
257
+ }
258
+ function findIndex ( array , predicate , thisArg ) {
259
+ if ( ! Array . prototype . findIndex ) {
260
+ // idx needs to be a Number, for..in returns string
261
+ for ( var idx = 0 ; idx < array . length ; idx ++ ) {
262
+ if ( predicate . call ( thisArg , array [ idx ] , idx , array ) ) {
263
+ return idx ;
264
+ }
265
+ }
266
+
267
+ return - 1 ;
268
+ }
269
+
270
+ return array . findIndex ( predicate , thisArg ) ;
271
+ }
272
+ function toArray ( arg ) {
273
+ if ( ! Array . from ) {
274
+ return Array . prototype . slice . call ( arg ) ;
275
+ }
276
+
277
+ return Array . from ( arg ) ;
278
+ }
279
+ function includes ( array , value ) {
280
+ if ( ! Array . prototype . includes ) {
281
+ for ( var idx in array ) {
282
+ if ( array [ idx ] === value ) {
283
+ return true ;
284
+ }
285
+ }
286
+
287
+ return false ;
288
+ }
289
+
290
+ return array . includes ( value ) ;
291
+ }
292
+
236
293
function ensureIsArray ( arg , key ) {
237
294
if ( ! key || ! isObject ( arg ) ) {
238
295
return isArray ( arg ) ? arg : [ ] ;
@@ -306,11 +363,12 @@ function createMixin(Vue, options) {
306
363
var rootKey = '$root' ;
307
364
var $root = this [ rootKey ] ;
308
365
var $options = this . $options ;
366
+ var devtoolsEnabled = Vue . config . devtools ;
309
367
Object . defineProperty ( this , '_hasMetaInfo' , {
310
368
configurable : true ,
311
369
get : function get ( ) {
312
370
// Show deprecation warning once when devtools enabled
313
- if ( Vue . config . devtools && ! $root [ rootConfigKey ] . deprecationWarningShown ) {
371
+ if ( devtoolsEnabled && ! $root [ rootConfigKey ] . deprecationWarningShown ) {
314
372
warn ( 'VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead' ) ;
315
373
$root [ rootConfigKey ] . deprecationWarningShown = true ;
316
374
}
@@ -330,6 +388,20 @@ function createMixin(Vue, options) {
330
388
appId : appId
331
389
} ;
332
390
appId ++ ;
391
+
392
+ if ( devtoolsEnabled && $root . $options [ options . keyName ] ) {
393
+ // use nextTick so the children should be added to $root
394
+ this . $nextTick ( function ( ) {
395
+ // find the first child that lists fnOptions
396
+ var child = find ( $root . $children , function ( c ) {
397
+ return c . $vnode && c . $vnode . fnOptions ;
398
+ } ) ;
399
+
400
+ if ( child && child . $vnode . fnOptions [ options . keyName ] ) {
401
+ warn ( "VueMeta has detected a possible global mixin which adds a " . concat ( options . keyName , " property to all Vue components on the page. This could cause severe performance issues. If possible, use $meta().addApp to add meta information instead" ) ) ;
402
+ }
403
+ } ) ;
404
+ }
333
405
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
334
406
// if _vueMeta = true it has info, if _vueMeta = false a child has info
335
407
@@ -373,14 +445,18 @@ function createMixin(Vue, options) {
373
445
$root [ rootConfigKey ] . initialized = this . $isServer ;
374
446
375
447
if ( ! $root [ rootConfigKey ] . initialized ) {
376
- ensuredPush ( $options , 'beforeMount' , function ( ) {
377
- var $root = this [ rootKey ] ; // if this Vue-app was server rendered, set the appId to 'ssr'
378
- // only one SSR app per page is supported
448
+ if ( ! $root [ rootConfigKey ] . initializedSsr ) {
449
+ $root [ rootConfigKey ] . initializedSsr = true ;
450
+ ensuredPush ( $options , 'beforeMount' , function ( ) {
451
+ var $root = this ; // if this Vue-app was server rendered, set the appId to 'ssr'
452
+ // only one SSR app per page is supported
453
+
454
+ if ( $root . $el && $root . $el . nodeType === 1 && $root . $el . hasAttribute ( 'data-server-rendered' ) ) {
455
+ $root [ rootConfigKey ] . appId = options . ssrAppId ;
456
+ }
457
+ } ) ;
458
+ } // we use the mounted hook here as on page load
379
459
380
- if ( $root . $el && $root . $el . nodeType === 1 && $root . $el . hasAttribute ( 'data-server-rendered' ) ) {
381
- $root [ rootConfigKey ] . appId = options . ssrAppId ;
382
- }
383
- } ) ; // we use the mounted hook here as on page load
384
460
385
461
ensuredPush ( $options , 'mounted' , function ( ) {
386
462
var $root = this [ rootKey ] ;
@@ -426,6 +502,7 @@ function createMixin(Vue, options) {
426
502
427
503
428
504
if ( this . $isServer ) {
505
+ /* istanbul ignore next */
429
506
return ;
430
507
} // no need to add this hooks on server side
431
508
@@ -448,6 +525,7 @@ function createMixin(Vue, options) {
448
525
return ;
449
526
}
450
527
528
+ delete this . _hasMetaInfo ;
451
529
this . $nextTick ( function ( ) {
452
530
if ( ! options . waitOnDestroyed || ! _this . $el || ! _this . $el . offsetParent ) {
453
531
triggerUpdate ( options , _this . $root , 'destroyed' ) ;
@@ -502,49 +580,6 @@ function getOptions(options) {
502
580
return optionsCopy ;
503
581
}
504
582
505
- /*
506
- * To reduce build size, this file provides simple polyfills without
507
- * overly excessive type checking and without modifying
508
- * the global Array.prototype
509
- * The polyfills are automatically removed in the commonjs build
510
- * Also, only files in client/ & shared/ should use these functions
511
- * files in server/ still use normal js function
512
- */
513
- function findIndex ( array , predicate , thisArg ) {
514
- if ( ! Array . prototype . findIndex ) {
515
- // idx needs to be a Number, for..in returns string
516
- for ( var idx = 0 ; idx < array . length ; idx ++ ) {
517
- if ( predicate . call ( thisArg , array [ idx ] , idx , array ) ) {
518
- return idx ;
519
- }
520
- }
521
-
522
- return - 1 ;
523
- }
524
-
525
- return array . findIndex ( predicate , thisArg ) ;
526
- }
527
- function toArray ( arg ) {
528
- if ( ! Array . from ) {
529
- return Array . prototype . slice . call ( arg ) ;
530
- }
531
-
532
- return Array . from ( arg ) ;
533
- }
534
- function includes ( array , value ) {
535
- if ( ! Array . prototype . includes ) {
536
- for ( var idx in array ) {
537
- if ( array [ idx ] === value ) {
538
- return true ;
539
- }
540
- }
541
-
542
- return false ;
543
- }
544
-
545
- return array . includes ( value ) ;
546
- }
547
-
548
583
var serverSequences = [ [ / & / g, '&' ] , [ / < / g, '<' ] , [ / > / g, '>' ] , [ / " / g, '"' ] , [ / ' / g, ''' ] ] ;
549
584
var clientSequences = [ [ / & / g, "&" ] , [ / < / g, "<" ] , [ / > / g, ">" ] , [ / " / g, "\"" ] , [ / ' / g, "'" ] ] ; // sanitizes potentially dangerous characters
550
585
@@ -820,14 +855,13 @@ function getComponentOption(options, component, result) {
820
855
// and set to the computed prop $metaInfo in the mixin
821
856
// using the computed prop should be a small performance increase
822
857
// because Vue caches those internally
823
- var data = $metaInfo || $options [ keyName ] ; // ignore data if its not an object, then we keep our previous result
858
+ var data = $metaInfo || $options [ keyName ] ; // only merge data with result when its an object
859
+ // eg it could be a function when metaInfo() returns undefined
860
+ // dueo to the or statement above
824
861
825
- if ( ! isObject ( data ) ) {
826
- return result ;
827
- } // merge with existing options
828
-
829
-
830
- result = merge ( result , data , options ) ;
862
+ if ( isObject ( data ) ) {
863
+ result = merge ( result , data , options ) ;
864
+ }
831
865
} // collect & aggregate child options if deep = true
832
866
833
867
@@ -1819,8 +1853,8 @@ function install(Vue, options) {
1819
1853
var index = {
1820
1854
version : version ,
1821
1855
install : install ,
1822
- generate : function generate$1 ( metaInfo ) {
1823
- return generate ( metaInfo ) ;
1856
+ generate : function generate$1 ( metaInfo , options ) {
1857
+ return generate ( metaInfo , options ) ;
1824
1858
} ,
1825
1859
hasMetaInfo : hasMetaInfo
1826
1860
} ;
0 commit comments