1
1
/**
2
- * vue-meta v2.3.2
2
+ * vue-meta v2.3.3
3
3
* (c) 2020
4
4
* - Declan de Wet
5
5
* - Sébastien Chopin (@Atinux)
@@ -14,9 +14,11 @@ 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.2 " ;
17
+ var version = "2.3.3 " ;
18
18
19
19
function _typeof ( obj ) {
20
+ "@babel/helpers - typeof" ;
21
+
20
22
if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) {
21
23
_typeof = function ( obj ) {
22
24
return typeof obj ;
@@ -220,7 +222,7 @@ var tagsWithoutEndTag = ['base', 'meta', 'link']; // HTML elements which can hav
220
222
var tagsWithInnerContent = [ 'noscript' , 'script' , 'style' ] ; // Attributes which are inserted as childNodes instead of HTMLAttribute
221
223
222
224
var tagAttributeAsInnerContent = [ 'innerHTML' , 'cssText' , 'json' ] ;
223
- var tagProperties = [ 'once' , 'template' ] ; // Attributes which should be added with data- prefix
225
+ var tagProperties = [ 'once' , 'skip' , ' template'] ; // Attributes which should be added with data- prefix
224
226
225
227
var commonDataAttributes = [ 'body' , 'pbody' ] ; // from: https://github.com/kangax/html-minifier/blob/gh-pages/src/htmlminifier.js#L202
226
228
@@ -325,22 +327,6 @@ function includes(array, value) {
325
327
return array . includes ( value ) ;
326
328
}
327
329
328
- function ensureIsArray ( arg , key ) {
329
- if ( ! key || ! isObject ( arg ) ) {
330
- return isArray ( arg ) ? arg : [ ] ;
331
- }
332
-
333
- if ( ! isArray ( arg [ key ] ) ) {
334
- arg [ key ] = [ ] ;
335
- }
336
-
337
- return arg ;
338
- }
339
- function ensuredPush ( object , key , el ) {
340
- ensureIsArray ( object , key ) ;
341
- object [ key ] . push ( el ) ;
342
- }
343
-
344
330
function hasMetaInfo ( vm ) {
345
331
vm = vm || this ;
346
332
return vm && ( vm [ rootConfigKey ] === true || isObject ( vm [ rootConfigKey ] ) ) ;
@@ -397,6 +383,8 @@ function createMixin(Vue, options) {
397
383
398
384
return {
399
385
beforeCreate : function beforeCreate ( ) {
386
+ var _this2 = this ;
387
+
400
388
var rootKey = '$root' ;
401
389
var $root = this [ rootKey ] ;
402
390
var $options = this . $options ;
@@ -466,7 +454,7 @@ function createMixin(Vue, options) {
466
454
// if computed $metaInfo exists, watch it for updates & trigger a refresh
467
455
// when it changes (i.e. automatically handle async actions that affect metaInfo)
468
456
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
469
- ensuredPush ( $options , ' created', function ( ) {
457
+ this . $on ( 'hook: created', function ( ) {
470
458
this . $watch ( '$metaInfo' , function ( ) {
471
459
triggerUpdate ( options , this [ rootKey ] , 'watcher' ) ;
472
460
} ) ;
@@ -484,7 +472,7 @@ function createMixin(Vue, options) {
484
472
if ( ! $root [ rootConfigKey ] . initialized ) {
485
473
if ( ! $root [ rootConfigKey ] . initializedSsr ) {
486
474
$root [ rootConfigKey ] . initializedSsr = true ;
487
- ensuredPush ( $options , ' beforeMount', function ( ) {
475
+ this . $on ( 'hook: beforeMount', function ( ) {
488
476
var $root = this ; // if this Vue-app was server rendered, set the appId to 'ssr'
489
477
// only one SSR app per page is supported
490
478
@@ -495,7 +483,7 @@ function createMixin(Vue, options) {
495
483
} // we use the mounted hook here as on page load
496
484
497
485
498
- ensuredPush ( $options , ' mounted', function ( ) {
486
+ this . $on ( 'hook: mounted', function ( ) {
499
487
var $root = this [ rootKey ] ;
500
488
501
489
if ( ! $root [ rootConfigKey ] . initialized ) {
@@ -535,8 +523,38 @@ function createMixin(Vue, options) {
535
523
addNavGuards ( $root ) ;
536
524
}
537
525
}
538
- } // do not trigger refresh on the server side
526
+ }
527
+
528
+ this . $on ( 'hook:destroyed' , function ( ) {
529
+ var _this = this ;
530
+
531
+ // do not trigger refresh:
532
+ // - when user configured to not wait for transitions on destroyed
533
+ // - when the component doesnt have a parent
534
+ // - doesnt have metaInfo defined
535
+ if ( ! this . $parent || ! hasMetaInfo ( this ) ) {
536
+ return ;
537
+ }
539
538
539
+ delete this . _hasMetaInfo ;
540
+ this . $nextTick ( function ( ) {
541
+ if ( ! options . waitOnDestroyed || ! _this . $el || ! _this . $el . offsetParent ) {
542
+ triggerUpdate ( options , _this . $root , 'destroyed' ) ;
543
+ return ;
544
+ } // Wait that element is hidden before refreshing meta tags (to support animations)
545
+
546
+
547
+ var interval = setInterval ( function ( ) {
548
+ if ( _this . $el && _this . $el . offsetParent !== null ) {
549
+ /* istanbul ignore next line */
550
+ return ;
551
+ }
552
+
553
+ clearInterval ( interval ) ;
554
+ triggerUpdate ( options , _this . $root , 'destroyed' ) ;
555
+ } , 50 ) ;
556
+ } ) ;
557
+ } ) ; // do not trigger refresh on the server side
540
558
541
559
if ( this . $isServer ) {
542
560
/* istanbul ignore next */
@@ -545,41 +563,10 @@ function createMixin(Vue, options) {
545
563
546
564
547
565
updateOnLifecycleHook . forEach ( function ( lifecycleHook ) {
548
- ensuredPush ( $options , lifecycleHook , function ( ) {
566
+ _this2 . $on ( "hook:" . concat ( lifecycleHook ) , function ( ) {
549
567
triggerUpdate ( options , this [ rootKey ] , lifecycleHook ) ;
550
568
} ) ;
551
569
} ) ;
552
- } ,
553
- // TODO: move back into beforeCreate when Vue issue is resolved
554
- destroyed : function destroyed ( ) {
555
- var _this = this ;
556
-
557
- // do not trigger refresh:
558
- // - when user configured to not wait for transitions on destroyed
559
- // - when the component doesnt have a parent
560
- // - doesnt have metaInfo defined
561
- if ( ! this . $parent || ! hasMetaInfo ( this ) ) {
562
- return ;
563
- }
564
-
565
- delete this . _hasMetaInfo ;
566
- this . $nextTick ( function ( ) {
567
- if ( ! options . waitOnDestroyed || ! _this . $el || ! _this . $el . offsetParent ) {
568
- triggerUpdate ( options , _this . $root , 'destroyed' ) ;
569
- return ;
570
- } // Wait that element is hidden before refreshing meta tags (to support animations)
571
-
572
-
573
- var interval = setInterval ( function ( ) {
574
- if ( _this . $el && _this . $el . offsetParent !== null ) {
575
- /* istanbul ignore next line */
576
- return ;
577
- }
578
-
579
- clearInterval ( interval ) ;
580
- triggerUpdate ( options , _this . $root , 'destroyed' ) ;
581
- } , 50 ) ;
582
- } ) ;
583
570
}
584
571
} ;
585
572
}
@@ -617,6 +604,18 @@ function getOptions(options) {
617
604
return optionsCopy ;
618
605
}
619
606
607
+ function ensureIsArray ( arg , key ) {
608
+ if ( ! key || ! isObject ( arg ) ) {
609
+ return isArray ( arg ) ? arg : [ ] ;
610
+ }
611
+
612
+ if ( ! isArray ( arg [ key ] ) ) {
613
+ arg [ key ] = [ ] ;
614
+ }
615
+
616
+ return arg ;
617
+ }
618
+
620
619
var serverSequences = [ [ / & / g, '&' ] , [ / < / g, '<' ] , [ / > / g, '>' ] , [ / " / g, '"' ] , [ / ' / g, ''' ] ] ;
621
620
var clientSequences = [ [ / & / g, "&" ] , [ / < / g, "<" ] , [ / > / g, ">" ] , [ / " / g, "\"" ] , [ / ' / g, "'" ] ] ; // sanitizes potentially dangerous characters
622
621
@@ -1196,7 +1195,11 @@ function updateTag(appId, options, type, tags, head, body) {
1196
1195
}
1197
1196
1198
1197
var newElement = document . createElement ( type ) ;
1199
- newElement . setAttribute ( attribute , appId ) ;
1198
+
1199
+ if ( ! tag . once ) {
1200
+ newElement . setAttribute ( attribute , appId ) ;
1201
+ }
1202
+
1200
1203
Object . keys ( tag ) . forEach ( function ( attr ) {
1201
1204
/* istanbul ignore next */
1202
1205
if ( includes ( tagProperties , attr ) ) {
0 commit comments