Skip to content

Commit 735be09

Browse files
committed
chore(release): 2.2.1
1 parent b01ea7b commit 735be09

8 files changed

+227
-127
lines changed

Diff for: CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [2.2.1](https://github.com/nuxt/vue-meta/compare/v2.2.0...v2.2.1) (2019-08-04)
6+
7+
8+
### Bug Fixes
9+
10+
* dont assign to global console ([2c0c4c3](https://github.com/nuxt/vue-meta/commit/2c0c4c3))
11+
* meta content templates ([#429](https://github.com/nuxt/vue-meta/issues/429)) ([6907f9a](https://github.com/nuxt/vue-meta/commit/6907f9a))
12+
513
## [2.2.0](https://github.com/nuxt/vue-meta/compare/v2.1.1...v2.2.0) (2019-07-28)
614

715

Diff for: dist/vue-meta.common.js

+55-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-meta v2.2.0
2+
* vue-meta v2.2.1
33
* (c) 2019
44
* - Declan de Wet
55
* - Sébastien Chopin (@Atinux)
@@ -13,7 +13,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
1313

1414
var deepmerge = _interopDefault(require('deepmerge'));
1515

16-
var version = "2.2.0";
16+
var version = "2.2.1";
1717

1818
// store an id to keep track of DOM updates
1919
var batchId = null;
@@ -206,7 +206,7 @@ var hasGlobalWindow = hasGlobalWindowFn();
206206

207207
var _global = hasGlobalWindow ? window : global;
208208

209-
var console = _global.console = _global.console || {};
209+
var console = _global.console || {};
210210
function warn(str) {
211211
/* istanbul ignore next */
212212
if (!console || !console.warn) {
@@ -438,7 +438,8 @@ var tagsWithoutEndTag = ['base', 'meta', 'link']; // HTML elements which can hav
438438

439439
var tagsWithInnerContent = ['noscript', 'script', 'style']; // Attributes which are inserted as childNodes instead of HTMLAttribute
440440

441-
var tagAttributeAsInnerContent = ['innerHTML', 'cssText', 'json']; // Attributes which should be added with data- prefix
441+
var tagAttributeAsInnerContent = ['innerHTML', 'cssText', 'json'];
442+
var tagProperties = ['once', 'template']; // Attributes which should be added with data- prefix
442443

443444
var commonDataAttributes = ['body', 'pbody']; // from: https://github.com/kangax/html-minifier/blob/gh-pages/src/htmlminifier.js#L202
444445

@@ -625,13 +626,23 @@ function applyTemplate(_ref, headObject, template, chunk) {
625626
metaTemplateKeyName = _ref.metaTemplateKeyName,
626627
contentKeyName = _ref.contentKeyName;
627628

628-
if (isUndefined(template)) {
629+
if (template === true || headObject[metaTemplateKeyName] === true) {
630+
// abort, template was already applied
631+
return false;
632+
}
633+
634+
if (isUndefined(template) && headObject[metaTemplateKeyName]) {
629635
template = headObject[metaTemplateKeyName];
630-
delete headObject[metaTemplateKeyName];
636+
headObject[metaTemplateKeyName] = true;
631637
} // return early if no template defined
632638

633639

634640
if (!template) {
641+
// cleanup faulty template properties
642+
if (headObject.hasOwnProperty(metaTemplateKeyName)) {
643+
delete headObject[metaTemplateKeyName];
644+
}
645+
635646
return false;
636647
}
637648

@@ -652,6 +663,11 @@ function _arrayMerge(_ref, target, source) {
652663
// but we check for a `vmid` property on each object in the array
653664
// using an O(1) lookup associative array exploit
654665
var destination = [];
666+
667+
if (!target.length && !source.length) {
668+
return destination;
669+
}
670+
655671
target.forEach(function (targetItem, targetIndex) {
656672
// no tagID so no need to check for duplicity
657673
if (!targetItem[tagIDKeyName]) {
@@ -702,9 +718,14 @@ function _arrayMerge(_ref, target, source) {
702718
component: component,
703719
metaTemplateKeyName: metaTemplateKeyName,
704720
contentKeyName: contentKeyName
705-
}, sourceItem, targetTemplate);
706-
} else if (!sourceItem[contentKeyName]) {
707-
// use child template and parent content
721+
}, sourceItem, targetTemplate); // set template to true to indicate template was already applied
722+
723+
sourceItem.template = true;
724+
return;
725+
}
726+
727+
if (!sourceItem[contentKeyName]) {
728+
// use parent content and child template
708729
applyTemplate({
709730
component: component,
710731
metaTemplateKeyName: metaTemplateKeyName,
@@ -770,9 +791,7 @@ function getComponentOption() {
770791
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
771792
var component = arguments.length > 1 ? arguments[1] : undefined;
772793
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
773-
var keyName = options.keyName,
774-
metaTemplateKeyName = options.metaTemplateKeyName,
775-
tagIDKeyName = options.tagIDKeyName;
794+
var keyName = options.keyName;
776795
var $options = component.$options,
777796
$children = component.$children;
778797

@@ -810,22 +829,6 @@ function getComponentOption() {
810829
});
811830
}
812831

813-
if (metaTemplateKeyName && result.meta) {
814-
// apply templates if needed
815-
result.meta.forEach(function (metaObject) {
816-
return applyTemplate(options, metaObject);
817-
}); // remove meta items with duplicate vmid's
818-
819-
result.meta = result.meta.filter(function (metaItem, index, arr) {
820-
return (// keep meta item if it doesnt has a vmid
821-
!metaItem.hasOwnProperty(tagIDKeyName) || // or if it's the first item in the array with this vmid
822-
index === findIndex(arr, function (item) {
823-
return item[tagIDKeyName] === metaItem[tagIDKeyName];
824-
})
825-
);
826-
});
827-
}
828-
829832
return result;
830833
}
831834

@@ -842,9 +845,9 @@ function getMetaInfo() {
842845
var info = arguments.length > 1 ? arguments[1] : undefined;
843846
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
844847
var component = arguments.length > 3 ? arguments[3] : undefined;
845-
846-
// Remove all "template" tags from meta
848+
var tagIDKeyName = options.tagIDKeyName; // Remove all "template" tags from meta
847849
// backup the title chunk in case user wants access to it
850+
848851
if (info.title) {
849852
info.titleChunk = info.title;
850853
} // replace title with populated template
@@ -863,6 +866,26 @@ function getMetaInfo() {
863866
info.base = Object.keys(info.base).length ? [info.base] : [];
864867
}
865868

869+
if (info.meta) {
870+
// remove meta items with duplicate vmid's
871+
info.meta = info.meta.filter(function (metaItem, index, arr) {
872+
var hasVmid = metaItem.hasOwnProperty(tagIDKeyName);
873+
874+
if (!hasVmid) {
875+
return true;
876+
}
877+
878+
var isFirstItemForVmid = index === findIndex(arr, function (item) {
879+
return item[tagIDKeyName] === metaItem[tagIDKeyName];
880+
});
881+
return isFirstItemForVmid;
882+
}); // apply templates if needed
883+
884+
info.meta.forEach(function (metaObject) {
885+
return applyTemplate(options, metaObject);
886+
});
887+
}
888+
866889
return escapeMetaInfo(options, info, escapeSequences);
867890
}
868891

@@ -1119,7 +1142,7 @@ function updateTag(appId) {
11191142

11201143
var _loop = function _loop(attr) {
11211144
/* istanbul ignore next */
1122-
if (!tag.hasOwnProperty(attr)) {
1145+
if (!tag.hasOwnProperty(attr) || includes(tagProperties, attr)) {
11231146
return "continue";
11241147
}
11251148

@@ -1436,7 +1459,7 @@ function tagGenerator() {
14361459

14371460
for (var attr in tag) {
14381461
// these attributes are treated as children on the tag
1439-
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
1462+
if (tagAttributeAsInnerContent.includes(attr) || tagProperties.includes(attr)) {
14401463
continue;
14411464
}
14421465

Diff for: dist/vue-meta.esm.browser.js

+53-30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* vue-meta v2.2.0
2+
* vue-meta v2.2.1
33
* (c) 2019
44
* - Declan de Wet
55
* - Sébastien Chopin (@Atinux)
@@ -9,7 +9,7 @@
99

1010
import deepmerge from 'deepmerge';
1111

12-
var version = "2.2.0";
12+
var version = "2.2.1";
1313

1414
// store an id to keep track of DOM updates
1515
var batchId = null;
@@ -182,7 +182,7 @@ var hasGlobalWindow = hasGlobalWindowFn();
182182

183183
var _global = hasGlobalWindow ? window : global;
184184

185-
var console = _global.console = _global.console || {};
185+
var console = _global.console || {};
186186
function warn(str) {
187187
/* istanbul ignore next */
188188
if (!console || !console.warn) {
@@ -411,6 +411,7 @@ var disableOptionKeys = ['__dangerouslyDisableSanitizers', '__dangerouslyDisable
411411
var metaInfoAttributeKeys = ['htmlAttrs', 'headAttrs', 'bodyAttrs']; // HTML elements which support the onload event
412412

413413
var tagsSupportingOnload = ['link', 'style', 'script']; // HTML elements which dont have a head tag (shortened to our needs)
414+
var tagProperties = ['once', 'template']; // Attributes which should be added with data- prefix
414415

415416
var commonDataAttributes = ['body', 'pbody']; // from: https://github.com/kangax/html-minifier/blob/gh-pages/src/htmlminifier.js#L202
416417

@@ -596,13 +597,23 @@ function applyTemplate(_ref, headObject, template, chunk) {
596597
metaTemplateKeyName = _ref.metaTemplateKeyName,
597598
contentKeyName = _ref.contentKeyName;
598599

599-
if (isUndefined(template)) {
600+
if (template === true || headObject[metaTemplateKeyName] === true) {
601+
// abort, template was already applied
602+
return false;
603+
}
604+
605+
if (isUndefined(template) && headObject[metaTemplateKeyName]) {
600606
template = headObject[metaTemplateKeyName];
601-
delete headObject[metaTemplateKeyName];
607+
headObject[metaTemplateKeyName] = true;
602608
} // return early if no template defined
603609

604610

605611
if (!template) {
612+
// cleanup faulty template properties
613+
if (headObject.hasOwnProperty(metaTemplateKeyName)) {
614+
delete headObject[metaTemplateKeyName];
615+
}
616+
606617
return false;
607618
}
608619

@@ -623,6 +634,11 @@ function _arrayMerge(_ref, target, source) {
623634
// but we check for a `vmid` property on each object in the array
624635
// using an O(1) lookup associative array exploit
625636
var destination = [];
637+
638+
if (!target.length && !source.length) {
639+
return destination;
640+
}
641+
626642
target.forEach(function (targetItem, targetIndex) {
627643
// no tagID so no need to check for duplicity
628644
if (!targetItem[tagIDKeyName]) {
@@ -673,9 +689,14 @@ function _arrayMerge(_ref, target, source) {
673689
component: component,
674690
metaTemplateKeyName: metaTemplateKeyName,
675691
contentKeyName: contentKeyName
676-
}, sourceItem, targetTemplate);
677-
} else if (!sourceItem[contentKeyName]) {
678-
// use child template and parent content
692+
}, sourceItem, targetTemplate); // set template to true to indicate template was already applied
693+
694+
sourceItem.template = true;
695+
return;
696+
}
697+
698+
if (!sourceItem[contentKeyName]) {
699+
// use parent content and child template
679700
applyTemplate({
680701
component: component,
681702
metaTemplateKeyName: metaTemplateKeyName,
@@ -741,9 +762,7 @@ function getComponentOption() {
741762
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
742763
var component = arguments.length > 1 ? arguments[1] : undefined;
743764
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
744-
var keyName = options.keyName,
745-
metaTemplateKeyName = options.metaTemplateKeyName,
746-
tagIDKeyName = options.tagIDKeyName;
765+
var keyName = options.keyName;
747766
var $options = component.$options,
748767
$children = component.$children;
749768

@@ -781,22 +800,6 @@ function getComponentOption() {
781800
});
782801
}
783802

784-
if (metaTemplateKeyName && result.meta) {
785-
// apply templates if needed
786-
result.meta.forEach(function (metaObject) {
787-
return applyTemplate(options, metaObject);
788-
}); // remove meta items with duplicate vmid's
789-
790-
result.meta = result.meta.filter(function (metaItem, index, arr) {
791-
return (// keep meta item if it doesnt has a vmid
792-
!metaItem.hasOwnProperty(tagIDKeyName) || // or if it's the first item in the array with this vmid
793-
index === findIndex(arr, function (item) {
794-
return item[tagIDKeyName] === metaItem[tagIDKeyName];
795-
})
796-
);
797-
});
798-
}
799-
800803
return result;
801804
}
802805

@@ -813,9 +816,9 @@ function getMetaInfo() {
813816
var info = arguments.length > 1 ? arguments[1] : undefined;
814817
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
815818
var component = arguments.length > 3 ? arguments[3] : undefined;
816-
817-
// Remove all "template" tags from meta
819+
var tagIDKeyName = options.tagIDKeyName; // Remove all "template" tags from meta
818820
// backup the title chunk in case user wants access to it
821+
819822
if (info.title) {
820823
info.titleChunk = info.title;
821824
} // replace title with populated template
@@ -834,6 +837,26 @@ function getMetaInfo() {
834837
info.base = Object.keys(info.base).length ? [info.base] : [];
835838
}
836839

840+
if (info.meta) {
841+
// remove meta items with duplicate vmid's
842+
info.meta = info.meta.filter(function (metaItem, index, arr) {
843+
var hasVmid = metaItem.hasOwnProperty(tagIDKeyName);
844+
845+
if (!hasVmid) {
846+
return true;
847+
}
848+
849+
var isFirstItemForVmid = index === findIndex(arr, function (item) {
850+
return item[tagIDKeyName] === metaItem[tagIDKeyName];
851+
});
852+
return isFirstItemForVmid;
853+
}); // apply templates if needed
854+
855+
info.meta.forEach(function (metaObject) {
856+
return applyTemplate(options, metaObject);
857+
});
858+
}
859+
837860
return escapeMetaInfo(options, info, escapeSequences);
838861
}
839862

@@ -1090,7 +1113,7 @@ function updateTag(appId) {
10901113

10911114
var _loop = function _loop(attr) {
10921115
/* istanbul ignore next */
1093-
if (!tag.hasOwnProperty(attr)) {
1116+
if (!tag.hasOwnProperty(attr) || includes(tagProperties, attr)) {
10941117
return "continue";
10951118
}
10961119

0 commit comments

Comments
 (0)