2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-25 16:10:34 +03:00

chore(release): 2.0.5

This commit is contained in:
pimlie
2019-07-11 20:39:11 +00:00
parent 56f6577e25
commit 62535d47fb
8 changed files with 343 additions and 305 deletions
+17
View File
@@ -2,6 +2,23 @@
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. 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.
### [2.0.5](https://github.com/nuxt/vue-meta/compare/v2.0.3...v2.0.5) (2019-07-11)
### Bug Fixes
* add warning for v1 boolean attribute syntax ([bfeab17](https://github.com/nuxt/vue-meta/commit/bfeab17))
* dont change title when value is undefined (fix [#396](https://github.com/nuxt/vue-meta/issues/396)) ([90f9710](https://github.com/nuxt/vue-meta/commit/90f9710))
* ensure hasAttribute exists on $root.$el ([f1511ac](https://github.com/nuxt/vue-meta/commit/f1511ac))
* only show boolean attrs with truthy value ([1d9072a](https://github.com/nuxt/vue-meta/commit/1d9072a))
### Tests
* enable all getMetaInfo tests again ([24d7fee](https://github.com/nuxt/vue-meta/commit/24d7fee))
### [2.0.4](https://github.com/nuxt/vue-meta/compare/v2.0.3...v2.0.4) (2019-06-22) ### [2.0.4](https://github.com/nuxt/vue-meta/compare/v2.0.3...v2.0.4) (2019-06-22)
+65 -54
View File
@@ -1,5 +1,5 @@
/** /**
* vue-meta v2.0.4 * vue-meta v2.0.5
* (c) 2019 * (c) 2019
* - Declan de Wet * - Declan de Wet
* - Sébastien Chopin (@Atinux) * - Sébastien Chopin (@Atinux)
@@ -13,12 +13,12 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
var deepmerge = _interopDefault(require('deepmerge')); var deepmerge = _interopDefault(require('deepmerge'));
var version = "2.0.4"; var version = "2.0.5";
// store an id to keep track of DOM updates // store an id to keep track of DOM updates
var batchId = null; var batchId = null;
function triggerUpdate(vm, hookName) { function triggerUpdate (vm, hookName) {
// if an update was triggered during initialization or when an update was triggered by the // if an update was triggered during initialization or when an update was triggered by the
// metaInfo watcher, set initialized to null // metaInfo watcher, set initialized to null
// then we keep falsy value but know we need to run a triggerUpdate after initialization // then we keep falsy value but know we need to run a triggerUpdate after initialization
@@ -39,7 +39,7 @@ function triggerUpdate(vm, hookName) {
* @param {Function} callback - the update to perform * @param {Function} callback - the update to perform
* @return {Number} id - a new ID * @return {Number} id - a new ID
*/ */
function batchUpdate(callback, timeout) { function batchUpdate (callback, timeout) {
if ( timeout === void 0 ) timeout = 10; if ( timeout === void 0 ) timeout = 10;
clearTimeout(batchId); clearTimeout(batchId);
@@ -56,27 +56,27 @@ function batchUpdate(callback, timeout) {
* @param {any} arg - the object to check * @param {any} arg - the object to check
* @return {Boolean} - true if `arg` is an array * @return {Boolean} - true if `arg` is an array
*/ */
function isArray(arg) { function isArray (arg) {
return Array.isArray(arg) return Array.isArray(arg)
} }
function isUndefined(arg) { function isUndefined (arg) {
return typeof arg === 'undefined' return typeof arg === 'undefined'
} }
function isObject(arg) { function isObject (arg) {
return typeof arg === 'object' return typeof arg === 'object'
} }
function isFunction(arg) { function isFunction (arg) {
return typeof arg === 'function' return typeof arg === 'function'
} }
function isString(arg) { function isString (arg) {
return typeof arg === 'string' return typeof arg === 'string'
} }
function ensureIsArray(arg, key) { function ensureIsArray (arg, key) {
if (!key || !isObject(arg)) { if (!key || !isObject(arg)) {
return isArray(arg) ? arg : [] return isArray(arg) ? arg : []
} }
@@ -87,27 +87,27 @@ function ensureIsArray(arg, key) {
return arg return arg
} }
function ensuredPush(object, key, el) { function ensuredPush (object, key, el) {
ensureIsArray(object, key); ensureIsArray(object, key);
object[key].push(el); object[key].push(el);
} }
// Vue $root instance has a _vueMeta object property, otherwise its a boolean true // Vue $root instance has a _vueMeta object property, otherwise its a boolean true
function hasMetaInfo(vm) { function hasMetaInfo (vm) {
if ( vm === void 0 ) vm = this; if ( vm === void 0 ) vm = this;
return vm && (vm._vueMeta === true || isObject(vm._vueMeta)) return vm && (vm._vueMeta === true || isObject(vm._vueMeta))
} }
// a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has // a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has
function inMetaInfoBranch(vm) { function inMetaInfoBranch (vm) {
if ( vm === void 0 ) vm = this; if ( vm === void 0 ) vm = this;
return vm && !isUndefined(vm._vueMeta) return vm && !isUndefined(vm._vueMeta)
} }
function addNavGuards(vm) { function addNavGuards (vm) {
// return when nav guards already added or no router exists // return when nav guards already added or no router exists
if (vm.$root._vueMeta.navGuards || !vm.$root.$router) { if (vm.$root._vueMeta.navGuards || !vm.$root.$router) {
/* istanbul ignore next */ /* istanbul ignore next */
@@ -135,18 +135,18 @@ function addNavGuards(vm) {
var appId = 1; var appId = 1;
function createMixin(Vue, options) { function createMixin (Vue, options) {
// for which Vue lifecycle hooks should the metaInfo be refreshed // for which Vue lifecycle hooks should the metaInfo be refreshed
var updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount']; var updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount'];
// watch for client side component updates // watch for client side component updates
return { return {
beforeCreate: function beforeCreate() { beforeCreate: function beforeCreate () {
var this$1 = this; var this$1 = this;
Object.defineProperty(this, '_hasMetaInfo', { Object.defineProperty(this, '_hasMetaInfo', {
configurable: true, configurable: true,
get: function get() { get: function get () {
// Show deprecation warning once when devtools enabled // Show deprecation warning once when devtools enabled
if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) { if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) {
console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console
@@ -210,7 +210,7 @@ function createMixin(Vue, options) {
ensuredPush(this.$options, 'beforeMount', function () { ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr' // if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported // only one SSR app per page is supported
if (this$1.$root.$el && this$1.$root.$el.hasAttribute('data-server-rendered')) { if (this$1.$root.$el && this$1.$root.$el.hasAttribute && this$1.$root.$el.hasAttribute('data-server-rendered')) {
this$1.$root._vueMeta.appId = 'ssr'; this$1.$root._vueMeta.appId = 'ssr';
} }
}); });
@@ -424,7 +424,7 @@ var booleanHtmlAttributes = [
'visible' 'visible'
]; ];
function setOptions(options) { function setOptions (options) {
// combine options // combine options
options = isObject(options) ? options : {}; options = isObject(options) ? options : {};
@@ -437,7 +437,7 @@ function setOptions(options) {
return options return options
} }
function getOptions(options) { function getOptions (options) {
var optionsCopy = {}; var optionsCopy = {};
for (var key in options) { for (var key in options) {
optionsCopy[key] = options[key]; optionsCopy[key] = options[key];
@@ -445,7 +445,7 @@ function getOptions(options) {
return optionsCopy return optionsCopy
} }
function pause(refresh) { function pause (refresh) {
if ( refresh === void 0 ) refresh = true; if ( refresh === void 0 ) refresh = true;
this.$root._vueMeta.paused = true; this.$root._vueMeta.paused = true;
@@ -453,7 +453,7 @@ function pause(refresh) {
return function () { return resume(refresh); } return function () { return resume(refresh); }
} }
function resume(refresh) { function resume (refresh) {
if ( refresh === void 0 ) refresh = true; if ( refresh === void 0 ) refresh = true;
this.$root._vueMeta.paused = false; this.$root._vueMeta.paused = false;
@@ -463,7 +463,7 @@ function resume(refresh) {
} }
} }
function applyTemplate(ref, headObject, template, chunk) { function applyTemplate (ref, headObject, template, chunk) {
var component = ref.component; var component = ref.component;
var metaTemplateKeyName = ref.metaTemplateKeyName; var metaTemplateKeyName = ref.metaTemplateKeyName;
var contentKeyName = ref.contentKeyName; var contentKeyName = ref.contentKeyName;
@@ -498,7 +498,7 @@ function applyTemplate(ref, headObject, template, chunk) {
* files in server/ still use normal js function * files in server/ still use normal js function
*/ */
function findIndex(array, predicate) { function findIndex (array, predicate) {
var arguments$1 = arguments; var arguments$1 = arguments;
if ( !Array.prototype.findIndex) { if ( !Array.prototype.findIndex) {
@@ -513,14 +513,14 @@ function findIndex(array, predicate) {
return array.findIndex(predicate, arguments[2]) return array.findIndex(predicate, arguments[2])
} }
function toArray(arg) { function toArray (arg) {
if ( !Array.from) { if ( !Array.from) {
return Array.prototype.slice.call(arg) return Array.prototype.slice.call(arg)
} }
return Array.from(arg) return Array.from(arg)
} }
function includes(array, value) { function includes (array, value) {
if ( !Array.prototype.includes) { if ( !Array.prototype.includes) {
for (var idx in array) { for (var idx in array) {
if (array[idx] === value) { if (array[idx] === value) {
@@ -543,14 +543,14 @@ var serverSequences = [
var clientSequences = [ var clientSequences = [
[/&/g, '\u0026'], [/&/g, '\u0026'],
[/</g, '\u003c'], [/</g, '\u003C'],
[/>/g, '\u003e'], [/>/g, '\u003E'],
[/"/g, '\u0022'], [/"/g, '\u0022'],
[/'/g, '\u0027'] [/'/g, '\u0027']
]; ];
// sanitizes potentially dangerous characters // sanitizes potentially dangerous characters
function escape(info, options, escapeOptions) { function escape (info, options, escapeOptions) {
var tagIDKeyName = options.tagIDKeyName; var tagIDKeyName = options.tagIDKeyName;
var doEscape = escapeOptions.doEscape; if ( doEscape === void 0 ) doEscape = function (v) { return v; }; var doEscape = escapeOptions.doEscape; if ( doEscape === void 0 ) doEscape = function (v) { return v; };
var escaped = {}; var escaped = {};
@@ -600,7 +600,7 @@ function escape(info, options, escapeOptions) {
return escaped return escaped
} }
function arrayMerge(ref, target, source) { function arrayMerge (ref, target, source) {
var component = ref.component; var component = ref.component;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
var metaTemplateKeyName = ref.metaTemplateKeyName; var metaTemplateKeyName = ref.metaTemplateKeyName;
@@ -667,7 +667,7 @@ function arrayMerge(ref, target, source) {
return destination.concat(source) return destination.concat(source)
} }
function merge(target, source, options) { function merge (target, source, options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
// remove properties explicitly set to false so child components can // remove properties explicitly set to false so child components can
@@ -712,7 +712,7 @@ function merge(target, source, options) {
* @param {Object} [result={}] - result so far * @param {Object} [result={}] - result so far
* @return {Object} result - final aggregated result * @return {Object} result - final aggregated result
*/ */
function getComponentOption(options, component, result) { function getComponentOption (options, component, result) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if ( result === void 0 ) result = {}; if ( result === void 0 ) result = {};
@@ -782,7 +782,7 @@ function getComponentOption(options, component, result) {
* @param {Object} component - the Vue instance to get meta info from * @param {Object} component - the Vue instance to get meta info from
* @return {Object} - returned meta info * @return {Object} - returned meta info
*/ */
function getMetaInfo(options, component, escapeSequences) { function getMetaInfo (options, component, escapeSequences) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if ( escapeSequences === void 0 ) escapeSequences = []; if ( escapeSequences === void 0 ) escapeSequences = [];
@@ -840,7 +840,7 @@ function getMetaInfo(options, component, escapeSequences) {
* @param {Object} attrs - the new document html attributes * @param {Object} attrs - the new document html attributes
* @param {HTMLElement} tag - the HTMLElement tag to update with new attrs * @param {HTMLElement} tag - the HTMLElement tag to update with new attrs
*/ */
function updateAttribute(ref, attrs, tag) { function updateAttribute (ref, attrs, tag) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
@@ -885,7 +885,7 @@ function updateAttribute(ref, attrs, tag) {
* *
* @param {String} title - the new title of the document * @param {String} title - the new title of the document
*/ */
function updateTitle(title) { function updateTitle (title) {
if (title === undefined) { if (title === undefined) {
return return
} }
@@ -901,7 +901,7 @@ function updateTitle(title) {
* @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base * @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base
* @return {Object} - a representation of what tags changed * @return {Object} - a representation of what tags changed
*/ */
function updateTag(appId, ref, type, tags, headTag, bodyTag) { function updateTag (appId, ref, type, tags, headTag, bodyTag) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
@@ -947,7 +947,13 @@ function updateTag(appId, ref, type, tags, headTag, bodyTag) {
var _attr = includes(dataAttributes, attr) var _attr = includes(dataAttributes, attr)
? ("data-" + attr) ? ("data-" + attr)
: attr; : attr;
var value = isUndefined(tag[attr]) || includes(booleanHtmlAttributes, attr) ? '' : tag[attr];
var isBooleanAttribute = includes(booleanHtmlAttributes, attr);
if (isBooleanAttribute && !tag[attr]) {
continue
}
var value = isBooleanAttribute ? '' : tag[attr];
newElement.setAttribute(_attr, value); newElement.setAttribute(_attr, value);
} }
} }
@@ -981,7 +987,7 @@ function updateTag(appId, ref, type, tags, headTag, bodyTag) {
return { oldTags: oldTags, newTags: newTags } return { oldTags: oldTags, newTags: newTags }
} }
function getTag(tags, tag) { function getTag (tags, tag) {
if (!tags[tag]) { if (!tags[tag]) {
tags[tag] = document.getElementsByTagName(tag)[0]; tags[tag] = document.getElementsByTagName(tag)[0];
} }
@@ -994,7 +1000,7 @@ function getTag(tags, tag) {
* *
* @param {Object} newInfo - the meta info to update to * @param {Object} newInfo - the meta info to update to
*/ */
function updateClientMetaInfo(appId, options, newInfo) { function updateClientMetaInfo (appId, options, newInfo) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
var ssrAttribute = options.ssrAttribute; var ssrAttribute = options.ssrAttribute;
@@ -1058,7 +1064,7 @@ function updateClientMetaInfo(appId, options, newInfo) {
return { addedTags: addedTags, removedTags: removedTags } return { addedTags: addedTags, removedTags: removedTags }
} }
function _refresh(options) { function _refresh (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
/** /**
@@ -1071,7 +1077,7 @@ function _refresh(options) {
* *
* @return {Object} - new meta info * @return {Object} - new meta info
*/ */
return function refresh() { return function refresh () {
var metaInfo = getMetaInfo(options, this.$root, clientSequences); var metaInfo = getMetaInfo(options, this.$root, clientSequences);
var appId = this.$root._vueMeta.appId; var appId = this.$root._vueMeta.appId;
@@ -1092,12 +1098,12 @@ function _refresh(options) {
* @param {Object} data - the attributes to generate * @param {Object} data - the attributes to generate
* @return {Object} - the attribute generator * @return {Object} - the attribute generator
*/ */
function attributeGenerator(ref, type, data) { function attributeGenerator (ref, type, data) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
return { return {
text: function text() { text: function text () {
var attributeStr = ''; var attributeStr = '';
var watchedAttrs = []; var watchedAttrs = [];
@@ -1126,12 +1132,12 @@ function attributeGenerator(ref, type, data) {
* @param {String} data - the title text * @param {String} data - the title text
* @return {Object} - the title generator * @return {Object} - the title generator
*/ */
function titleGenerator(appId, ref, type, data) { function titleGenerator (appId, ref, type, data) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
return { return {
text: function text() { text: function text () {
return ("<" + type + ">" + data + "</" + type + ">") return ("<" + type + ">" + data + "</" + type + ">")
} }
} }
@@ -1144,13 +1150,13 @@ function titleGenerator(appId, ref, type, data) {
* @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base * @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base
* @return {Object} - the tag generator * @return {Object} - the tag generator
*/ */
function tagGenerator(appId, ref, type, tags) { function tagGenerator (appId, ref, type, tags) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
return { return {
text: function text(ref) { text: function text (ref) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var body = ref.body; if ( body === void 0 ) body = false; var body = ref.body; if ( body === void 0 ) body = false;
@@ -1179,7 +1185,12 @@ function tagGenerator(appId, ref, type, tags) {
prefix = 'data-'; prefix = 'data-';
} }
return isUndefined(tag[attr]) || booleanHtmlAttributes.includes(attr) var isBooleanAttr = booleanHtmlAttributes.includes(attr);
if (isBooleanAttr && !tag[attr]) {
return attrsStr
}
return isBooleanAttr
? (attrsStr + " " + prefix + attr) ? (attrsStr + " " + prefix + attr)
: (attrsStr + " " + prefix + attr + "=\"" + (tag[attr]) + "\"") : (attrsStr + " " + prefix + attr + "=\"" + (tag[attr]) + "\"")
}, ''); }, '');
@@ -1215,7 +1226,7 @@ function tagGenerator(appId, ref, type, tags) {
* @return {Object} - the new injector * @return {Object} - the new injector
*/ */
function generateServerInjector(appId, options, type, data) { function generateServerInjector (appId, options, type, data) {
if (type === 'title') { if (type === 'title') {
return titleGenerator(appId, options, type, data) return titleGenerator(appId, options, type, data)
} }
@@ -1227,7 +1238,7 @@ function generateServerInjector(appId, options, type, data) {
return tagGenerator(appId, options, type, data) return tagGenerator(appId, options, type, data)
} }
function _inject(options) { function _inject (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
/** /**
@@ -1237,7 +1248,7 @@ function _inject(options) {
* @this {Object} - Vue instance - ideally the root component * @this {Object} - Vue instance - ideally the root component
* @return {Object} - server meta info with `toString` methods * @return {Object} - server meta info with `toString` methods
*/ */
return function inject() { return function inject () {
// get meta info with sensible defaults // get meta info with sensible defaults
var metaInfo = getMetaInfo(options, this.$root, serverSequences); var metaInfo = getMetaInfo(options, this.$root, serverSequences);
@@ -1252,7 +1263,7 @@ function _inject(options) {
} }
} }
function _$meta(options) { function _$meta (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
var _refresh$1 = _refresh(options); var _refresh$1 = _refresh(options);
@@ -1263,7 +1274,7 @@ function _$meta(options) {
* @this {Object} - the Vue instance (a root component) * @this {Object} - the Vue instance (a root component)
* @return {Object} - injector * @return {Object} - injector
*/ */
return function $meta() { return function $meta () {
return { return {
getOptions: function () { return getOptions(options); }, getOptions: function () { return getOptions(options); },
refresh: _refresh$1.bind(this), refresh: _refresh$1.bind(this),
@@ -1278,7 +1289,7 @@ function _$meta(options) {
* Plugin install function. * Plugin install function.
* @param {Function} Vue - the Vue constructor. * @param {Function} Vue - the Vue constructor.
*/ */
function install(Vue, options) { function install (Vue, options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if (Vue.__vuemeta_installed) { if (Vue.__vuemeta_installed) {
+50 -44
View File
@@ -1,5 +1,5 @@
/** /**
* vue-meta v2.0.4 * vue-meta v2.0.5
* (c) 2019 * (c) 2019
* - Declan de Wet * - Declan de Wet
* - Sébastien Chopin (@Atinux) * - Sébastien Chopin (@Atinux)
@@ -9,12 +9,12 @@
import deepmerge from 'deepmerge'; import deepmerge from 'deepmerge';
var version = "2.0.4"; var version = "2.0.5";
// store an id to keep track of DOM updates // store an id to keep track of DOM updates
let batchId = null; let batchId = null;
function triggerUpdate(vm, hookName) { function triggerUpdate (vm, hookName) {
// if an update was triggered during initialization or when an update was triggered by the // if an update was triggered during initialization or when an update was triggered by the
// metaInfo watcher, set initialized to null // metaInfo watcher, set initialized to null
// then we keep falsy value but know we need to run a triggerUpdate after initialization // then we keep falsy value but know we need to run a triggerUpdate after initialization
@@ -35,7 +35,7 @@ function triggerUpdate(vm, hookName) {
* @param {Function} callback - the update to perform * @param {Function} callback - the update to perform
* @return {Number} id - a new ID * @return {Number} id - a new ID
*/ */
function batchUpdate(callback, timeout = 10) { function batchUpdate (callback, timeout = 10) {
clearTimeout(batchId); clearTimeout(batchId);
batchId = setTimeout(() => { batchId = setTimeout(() => {
@@ -50,27 +50,27 @@ function batchUpdate(callback, timeout = 10) {
* @param {any} arg - the object to check * @param {any} arg - the object to check
* @return {Boolean} - true if `arg` is an array * @return {Boolean} - true if `arg` is an array
*/ */
function isArray(arg) { function isArray (arg) {
return Array.isArray(arg) return Array.isArray(arg)
} }
function isUndefined(arg) { function isUndefined (arg) {
return typeof arg === 'undefined' return typeof arg === 'undefined'
} }
function isObject(arg) { function isObject (arg) {
return typeof arg === 'object' return typeof arg === 'object'
} }
function isFunction(arg) { function isFunction (arg) {
return typeof arg === 'function' return typeof arg === 'function'
} }
function isString(arg) { function isString (arg) {
return typeof arg === 'string' return typeof arg === 'string'
} }
function ensureIsArray(arg, key) { function ensureIsArray (arg, key) {
if (!key || !isObject(arg)) { if (!key || !isObject(arg)) {
return isArray(arg) ? arg : [] return isArray(arg) ? arg : []
} }
@@ -81,23 +81,23 @@ function ensureIsArray(arg, key) {
return arg return arg
} }
function ensuredPush(object, key, el) { function ensuredPush (object, key, el) {
ensureIsArray(object, key); ensureIsArray(object, key);
object[key].push(el); object[key].push(el);
} }
// Vue $root instance has a _vueMeta object property, otherwise its a boolean true // Vue $root instance has a _vueMeta object property, otherwise its a boolean true
function hasMetaInfo(vm = this) { function hasMetaInfo (vm = this) {
return vm && (vm._vueMeta === true || isObject(vm._vueMeta)) return vm && (vm._vueMeta === true || isObject(vm._vueMeta))
} }
// a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has // a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has
function inMetaInfoBranch(vm = this) { function inMetaInfoBranch (vm = this) {
return vm && !isUndefined(vm._vueMeta) return vm && !isUndefined(vm._vueMeta)
} }
function addNavGuards(vm) { function addNavGuards (vm) {
// return when nav guards already added or no router exists // return when nav guards already added or no router exists
if (vm.$root._vueMeta.navGuards || !vm.$root.$router) { if (vm.$root._vueMeta.navGuards || !vm.$root.$router) {
/* istanbul ignore next */ /* istanbul ignore next */
@@ -124,16 +124,16 @@ function addNavGuards(vm) {
let appId = 1; let appId = 1;
function createMixin(Vue, options) { function createMixin (Vue, options) {
// for which Vue lifecycle hooks should the metaInfo be refreshed // for which Vue lifecycle hooks should the metaInfo be refreshed
const updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount']; const updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount'];
// watch for client side component updates // watch for client side component updates
return { return {
beforeCreate() { beforeCreate () {
Object.defineProperty(this, '_hasMetaInfo', { Object.defineProperty(this, '_hasMetaInfo', {
configurable: true, configurable: true,
get() { get () {
// Show deprecation warning once when devtools enabled // Show deprecation warning once when devtools enabled
if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) { if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) {
console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console
@@ -197,7 +197,7 @@ function createMixin(Vue, options) {
ensuredPush(this.$options, 'beforeMount', () => { ensuredPush(this.$options, 'beforeMount', () => {
// if this Vue-app was server rendered, set the appId to 'ssr' // if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported // only one SSR app per page is supported
if (this.$root.$el && this.$root.$el.hasAttribute('data-server-rendered')) { if (this.$root.$el && this.$root.$el.hasAttribute && this.$root.$el.hasAttribute('data-server-rendered')) {
this.$root._vueMeta.appId = 'ssr'; this.$root._vueMeta.appId = 'ssr';
} }
}); });
@@ -400,7 +400,7 @@ const booleanHtmlAttributes = [
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
const showWarningNotSupported = () => console.warn('This vue app/component has no vue-meta configuration'); const showWarningNotSupported = () => console.warn('This vue app/component has no vue-meta configuration');
function setOptions(options) { function setOptions (options) {
// combine options // combine options
options = isObject(options) ? options : {}; options = isObject(options) ? options : {};
@@ -413,7 +413,7 @@ function setOptions(options) {
return options return options
} }
function getOptions(options) { function getOptions (options) {
const optionsCopy = {}; const optionsCopy = {};
for (const key in options) { for (const key in options) {
optionsCopy[key] = options[key]; optionsCopy[key] = options[key];
@@ -421,13 +421,13 @@ function getOptions(options) {
return optionsCopy return optionsCopy
} }
function pause(refresh = true) { function pause (refresh = true) {
this.$root._vueMeta.paused = true; this.$root._vueMeta.paused = true;
return () => resume(refresh) return () => resume(refresh)
} }
function resume(refresh = true) { function resume (refresh = true) {
this.$root._vueMeta.paused = false; this.$root._vueMeta.paused = false;
if (refresh) { if (refresh) {
@@ -435,7 +435,7 @@ function resume(refresh = true) {
} }
} }
function applyTemplate({ component, metaTemplateKeyName, contentKeyName }, headObject, template, chunk) { function applyTemplate ({ component, metaTemplateKeyName, contentKeyName }, headObject, template, chunk) {
if (isUndefined(template)) { if (isUndefined(template)) {
template = headObject[metaTemplateKeyName]; template = headObject[metaTemplateKeyName];
delete headObject[metaTemplateKeyName]; delete headObject[metaTemplateKeyName];
@@ -466,28 +466,28 @@ function applyTemplate({ component, metaTemplateKeyName, contentKeyName }, headO
* files in server/ still use normal js function * files in server/ still use normal js function
*/ */
function findIndex(array, predicate) { function findIndex (array, predicate) {
return array.findIndex(predicate, arguments[2]) return array.findIndex(predicate, arguments[2])
} }
function toArray(arg) { function toArray (arg) {
return Array.from(arg) return Array.from(arg)
} }
function includes(array, value) { function includes (array, value) {
return array.includes(value) return array.includes(value)
} }
const clientSequences = [ const clientSequences = [
[/&/g, '\u0026'], [/&/g, '\u0026'],
[/</g, '\u003c'], [/</g, '\u003C'],
[/>/g, '\u003e'], [/>/g, '\u003E'],
[/"/g, '\u0022'], [/"/g, '\u0022'],
[/'/g, '\u0027'] [/'/g, '\u0027']
]; ];
// sanitizes potentially dangerous characters // sanitizes potentially dangerous characters
function escape(info, options, escapeOptions) { function escape (info, options, escapeOptions) {
const { tagIDKeyName } = options; const { tagIDKeyName } = options;
const { doEscape = v => v } = escapeOptions; const { doEscape = v => v } = escapeOptions;
const escaped = {}; const escaped = {};
@@ -537,7 +537,7 @@ function escape(info, options, escapeOptions) {
return escaped return escaped
} }
function arrayMerge({ component, tagIDKeyName, metaTemplateKeyName, contentKeyName }, target, source) { function arrayMerge ({ component, tagIDKeyName, metaTemplateKeyName, contentKeyName }, target, source) {
// we concat the arrays without merging objects contained in, // we concat the arrays without merging objects contained in,
// but we check for a `vmid` property on each object in the array // but we check for a `vmid` property on each object in the array
// using an O(1) lookup associative array exploit // using an O(1) lookup associative array exploit
@@ -599,7 +599,7 @@ function arrayMerge({ component, tagIDKeyName, metaTemplateKeyName, contentKeyNa
return destination.concat(source) return destination.concat(source)
} }
function merge(target, source, options = {}) { function merge (target, source, options = {}) {
// remove properties explicitly set to false so child components can // remove properties explicitly set to false so child components can
// optionally _not_ overwrite the parents content // optionally _not_ overwrite the parents content
// (for array properties this is checked in arrayMerge) // (for array properties this is checked in arrayMerge)
@@ -642,7 +642,7 @@ function merge(target, source, options = {}) {
* @param {Object} [result={}] - result so far * @param {Object} [result={}] - result so far
* @return {Object} result - final aggregated result * @return {Object} result - final aggregated result
*/ */
function getComponentOption(options = {}, component, result = {}) { function getComponentOption (options = {}, component, result = {}) {
const { keyName, metaTemplateKeyName, tagIDKeyName } = options; const { keyName, metaTemplateKeyName, tagIDKeyName } = options;
const { $options, $children } = component; const { $options, $children } = component;
@@ -706,7 +706,7 @@ function getComponentOption(options = {}, component, result = {}) {
* @param {Object} component - the Vue instance to get meta info from * @param {Object} component - the Vue instance to get meta info from
* @return {Object} - returned meta info * @return {Object} - returned meta info
*/ */
function getMetaInfo(options = {}, component, escapeSequences = []) { function getMetaInfo (options = {}, component, escapeSequences = []) {
// collect & aggregate all metaInfo $options // collect & aggregate all metaInfo $options
let info = getComponentOption(options, component, defaultInfo); let info = getComponentOption(options, component, defaultInfo);
@@ -756,7 +756,7 @@ function getMetaInfo(options = {}, component, escapeSequences = []) {
* @param {Object} attrs - the new document html attributes * @param {Object} attrs - the new document html attributes
* @param {HTMLElement} tag - the HTMLElement tag to update with new attrs * @param {HTMLElement} tag - the HTMLElement tag to update with new attrs
*/ */
function updateAttribute({ attribute } = {}, attrs, tag) { function updateAttribute ({ attribute } = {}, attrs, tag) {
const vueMetaAttrString = tag.getAttribute(attribute); const vueMetaAttrString = tag.getAttribute(attribute);
const vueMetaAttrs = vueMetaAttrString ? vueMetaAttrString.split(',') : []; const vueMetaAttrs = vueMetaAttrString ? vueMetaAttrString.split(',') : [];
const toRemove = toArray(vueMetaAttrs); const toRemove = toArray(vueMetaAttrs);
@@ -798,7 +798,7 @@ function updateAttribute({ attribute } = {}, attrs, tag) {
* *
* @param {String} title - the new title of the document * @param {String} title - the new title of the document
*/ */
function updateTitle(title) { function updateTitle (title) {
if (title === undefined) { if (title === undefined) {
return return
} }
@@ -814,7 +814,7 @@ function updateTitle(title) {
* @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base * @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base
* @return {Object} - a representation of what tags changed * @return {Object} - a representation of what tags changed
*/ */
function updateTag(appId, { attribute, tagIDKeyName } = {}, type, tags, headTag, bodyTag) { function updateTag (appId, { attribute, tagIDKeyName } = {}, type, tags, headTag, bodyTag) {
const oldHeadTags = toArray(headTag.querySelectorAll(`${type}[${attribute}="${appId}"], ${type}[data-${tagIDKeyName}]`)); const oldHeadTags = toArray(headTag.querySelectorAll(`${type}[${attribute}="${appId}"], ${type}[data-${tagIDKeyName}]`));
const oldBodyTags = toArray(bodyTag.querySelectorAll(`${type}[${attribute}="${appId}"][data-body="true"], ${type}[data-${tagIDKeyName}][data-body="true"]`)); const oldBodyTags = toArray(bodyTag.querySelectorAll(`${type}[${attribute}="${appId}"][data-body="true"], ${type}[data-${tagIDKeyName}][data-body="true"]`));
const dataAttributes = [tagIDKeyName, 'body']; const dataAttributes = [tagIDKeyName, 'body'];
@@ -856,7 +856,13 @@ function updateTag(appId, { attribute, tagIDKeyName } = {}, type, tags, headTag,
const _attr = includes(dataAttributes, attr) const _attr = includes(dataAttributes, attr)
? `data-${attr}` ? `data-${attr}`
: attr; : attr;
const value = isUndefined(tag[attr]) || includes(booleanHtmlAttributes, attr) ? '' : tag[attr];
const isBooleanAttribute = includes(booleanHtmlAttributes, attr);
if (isBooleanAttribute && !tag[attr]) {
continue
}
const value = isBooleanAttribute ? '' : tag[attr];
newElement.setAttribute(_attr, value); newElement.setAttribute(_attr, value);
} }
} }
@@ -890,7 +896,7 @@ function updateTag(appId, { attribute, tagIDKeyName } = {}, type, tags, headTag,
return { oldTags, newTags } return { oldTags, newTags }
} }
function getTag(tags, tag) { function getTag (tags, tag) {
if (!tags[tag]) { if (!tags[tag]) {
tags[tag] = document.getElementsByTagName(tag)[0]; tags[tag] = document.getElementsByTagName(tag)[0];
} }
@@ -903,7 +909,7 @@ function getTag(tags, tag) {
* *
* @param {Object} newInfo - the meta info to update to * @param {Object} newInfo - the meta info to update to
*/ */
function updateClientMetaInfo(appId, options = {}, newInfo) { function updateClientMetaInfo (appId, options = {}, newInfo) {
const { ssrAttribute } = options; const { ssrAttribute } = options;
// only cache tags for current update // only cache tags for current update
@@ -963,7 +969,7 @@ function updateClientMetaInfo(appId, options = {}, newInfo) {
return { addedTags, removedTags } return { addedTags, removedTags }
} }
function _refresh(options = {}) { function _refresh (options = {}) {
/** /**
* When called, will update the current meta info with new meta info. * When called, will update the current meta info with new meta info.
* Useful when updating meta info as the result of an asynchronous * Useful when updating meta info as the result of an asynchronous
@@ -974,7 +980,7 @@ function _refresh(options = {}) {
* *
* @return {Object} - new meta info * @return {Object} - new meta info
*/ */
return function refresh() { return function refresh () {
const metaInfo = getMetaInfo(options, this.$root, clientSequences); const metaInfo = getMetaInfo(options, this.$root, clientSequences);
const appId = this.$root._vueMeta.appId; const appId = this.$root._vueMeta.appId;
@@ -988,7 +994,7 @@ function _refresh(options = {}) {
} }
} }
function _$meta(options = {}) { function _$meta (options = {}) {
const _refresh$1 = _refresh(options); const _refresh$1 = _refresh(options);
const inject = () => {}; const inject = () => {};
@@ -997,7 +1003,7 @@ function _$meta(options = {}) {
* @this {Object} - the Vue instance (a root component) * @this {Object} - the Vue instance (a root component)
* @return {Object} - injector * @return {Object} - injector
*/ */
return function $meta() { return function $meta () {
if (!this.$root._vueMeta) { if (!this.$root._vueMeta) {
return { return {
getOptions: showWarningNotSupported, getOptions: showWarningNotSupported,
@@ -1022,7 +1028,7 @@ function _$meta(options = {}) {
* Plugin install function. * Plugin install function.
* @param {Function} Vue - the Vue constructor. * @param {Function} Vue - the Vue constructor.
*/ */
function install(Vue, options = {}) { function install (Vue, options = {}) {
if (Vue.__vuemeta_installed) { if (Vue.__vuemeta_installed) {
return return
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+65 -54
View File
@@ -1,5 +1,5 @@
/** /**
* vue-meta v2.0.4 * vue-meta v2.0.5
* (c) 2019 * (c) 2019
* - Declan de Wet * - Declan de Wet
* - Sébastien Chopin (@Atinux) * - Sébastien Chopin (@Atinux)
@@ -9,12 +9,12 @@
import deepmerge from 'deepmerge'; import deepmerge from 'deepmerge';
var version = "2.0.4"; var version = "2.0.5";
// store an id to keep track of DOM updates // store an id to keep track of DOM updates
var batchId = null; var batchId = null;
function triggerUpdate(vm, hookName) { function triggerUpdate (vm, hookName) {
// if an update was triggered during initialization or when an update was triggered by the // if an update was triggered during initialization or when an update was triggered by the
// metaInfo watcher, set initialized to null // metaInfo watcher, set initialized to null
// then we keep falsy value but know we need to run a triggerUpdate after initialization // then we keep falsy value but know we need to run a triggerUpdate after initialization
@@ -35,7 +35,7 @@ function triggerUpdate(vm, hookName) {
* @param {Function} callback - the update to perform * @param {Function} callback - the update to perform
* @return {Number} id - a new ID * @return {Number} id - a new ID
*/ */
function batchUpdate(callback, timeout) { function batchUpdate (callback, timeout) {
if ( timeout === void 0 ) timeout = 10; if ( timeout === void 0 ) timeout = 10;
clearTimeout(batchId); clearTimeout(batchId);
@@ -52,27 +52,27 @@ function batchUpdate(callback, timeout) {
* @param {any} arg - the object to check * @param {any} arg - the object to check
* @return {Boolean} - true if `arg` is an array * @return {Boolean} - true if `arg` is an array
*/ */
function isArray(arg) { function isArray (arg) {
return Array.isArray(arg) return Array.isArray(arg)
} }
function isUndefined(arg) { function isUndefined (arg) {
return typeof arg === 'undefined' return typeof arg === 'undefined'
} }
function isObject(arg) { function isObject (arg) {
return typeof arg === 'object' return typeof arg === 'object'
} }
function isFunction(arg) { function isFunction (arg) {
return typeof arg === 'function' return typeof arg === 'function'
} }
function isString(arg) { function isString (arg) {
return typeof arg === 'string' return typeof arg === 'string'
} }
function ensureIsArray(arg, key) { function ensureIsArray (arg, key) {
if (!key || !isObject(arg)) { if (!key || !isObject(arg)) {
return isArray(arg) ? arg : [] return isArray(arg) ? arg : []
} }
@@ -83,27 +83,27 @@ function ensureIsArray(arg, key) {
return arg return arg
} }
function ensuredPush(object, key, el) { function ensuredPush (object, key, el) {
ensureIsArray(object, key); ensureIsArray(object, key);
object[key].push(el); object[key].push(el);
} }
// Vue $root instance has a _vueMeta object property, otherwise its a boolean true // Vue $root instance has a _vueMeta object property, otherwise its a boolean true
function hasMetaInfo(vm) { function hasMetaInfo (vm) {
if ( vm === void 0 ) vm = this; if ( vm === void 0 ) vm = this;
return vm && (vm._vueMeta === true || isObject(vm._vueMeta)) return vm && (vm._vueMeta === true || isObject(vm._vueMeta))
} }
// a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has // a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has
function inMetaInfoBranch(vm) { function inMetaInfoBranch (vm) {
if ( vm === void 0 ) vm = this; if ( vm === void 0 ) vm = this;
return vm && !isUndefined(vm._vueMeta) return vm && !isUndefined(vm._vueMeta)
} }
function addNavGuards(vm) { function addNavGuards (vm) {
// return when nav guards already added or no router exists // return when nav guards already added or no router exists
if (vm.$root._vueMeta.navGuards || !vm.$root.$router) { if (vm.$root._vueMeta.navGuards || !vm.$root.$router) {
/* istanbul ignore next */ /* istanbul ignore next */
@@ -131,18 +131,18 @@ function addNavGuards(vm) {
var appId = 1; var appId = 1;
function createMixin(Vue, options) { function createMixin (Vue, options) {
// for which Vue lifecycle hooks should the metaInfo be refreshed // for which Vue lifecycle hooks should the metaInfo be refreshed
var updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount']; var updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount'];
// watch for client side component updates // watch for client side component updates
return { return {
beforeCreate: function beforeCreate() { beforeCreate: function beforeCreate () {
var this$1 = this; var this$1 = this;
Object.defineProperty(this, '_hasMetaInfo', { Object.defineProperty(this, '_hasMetaInfo', {
configurable: true, configurable: true,
get: function get() { get: function get () {
// Show deprecation warning once when devtools enabled // Show deprecation warning once when devtools enabled
if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) { if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) {
console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console
@@ -206,7 +206,7 @@ function createMixin(Vue, options) {
ensuredPush(this.$options, 'beforeMount', function () { ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr' // if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported // only one SSR app per page is supported
if (this$1.$root.$el && this$1.$root.$el.hasAttribute('data-server-rendered')) { if (this$1.$root.$el && this$1.$root.$el.hasAttribute && this$1.$root.$el.hasAttribute('data-server-rendered')) {
this$1.$root._vueMeta.appId = 'ssr'; this$1.$root._vueMeta.appId = 'ssr';
} }
}); });
@@ -420,7 +420,7 @@ var booleanHtmlAttributes = [
'visible' 'visible'
]; ];
function setOptions(options) { function setOptions (options) {
// combine options // combine options
options = isObject(options) ? options : {}; options = isObject(options) ? options : {};
@@ -433,7 +433,7 @@ function setOptions(options) {
return options return options
} }
function getOptions(options) { function getOptions (options) {
var optionsCopy = {}; var optionsCopy = {};
for (var key in options) { for (var key in options) {
optionsCopy[key] = options[key]; optionsCopy[key] = options[key];
@@ -441,7 +441,7 @@ function getOptions(options) {
return optionsCopy return optionsCopy
} }
function pause(refresh) { function pause (refresh) {
if ( refresh === void 0 ) refresh = true; if ( refresh === void 0 ) refresh = true;
this.$root._vueMeta.paused = true; this.$root._vueMeta.paused = true;
@@ -449,7 +449,7 @@ function pause(refresh) {
return function () { return resume(refresh); } return function () { return resume(refresh); }
} }
function resume(refresh) { function resume (refresh) {
if ( refresh === void 0 ) refresh = true; if ( refresh === void 0 ) refresh = true;
this.$root._vueMeta.paused = false; this.$root._vueMeta.paused = false;
@@ -459,7 +459,7 @@ function resume(refresh) {
} }
} }
function applyTemplate(ref, headObject, template, chunk) { function applyTemplate (ref, headObject, template, chunk) {
var component = ref.component; var component = ref.component;
var metaTemplateKeyName = ref.metaTemplateKeyName; var metaTemplateKeyName = ref.metaTemplateKeyName;
var contentKeyName = ref.contentKeyName; var contentKeyName = ref.contentKeyName;
@@ -494,7 +494,7 @@ function applyTemplate(ref, headObject, template, chunk) {
* files in server/ still use normal js function * files in server/ still use normal js function
*/ */
function findIndex(array, predicate) { function findIndex (array, predicate) {
var arguments$1 = arguments; var arguments$1 = arguments;
if ( !Array.prototype.findIndex) { if ( !Array.prototype.findIndex) {
@@ -509,14 +509,14 @@ function findIndex(array, predicate) {
return array.findIndex(predicate, arguments[2]) return array.findIndex(predicate, arguments[2])
} }
function toArray(arg) { function toArray (arg) {
if ( !Array.from) { if ( !Array.from) {
return Array.prototype.slice.call(arg) return Array.prototype.slice.call(arg)
} }
return Array.from(arg) return Array.from(arg)
} }
function includes(array, value) { function includes (array, value) {
if ( !Array.prototype.includes) { if ( !Array.prototype.includes) {
for (var idx in array) { for (var idx in array) {
if (array[idx] === value) { if (array[idx] === value) {
@@ -539,14 +539,14 @@ var serverSequences = [
var clientSequences = [ var clientSequences = [
[/&/g, '\u0026'], [/&/g, '\u0026'],
[/</g, '\u003c'], [/</g, '\u003C'],
[/>/g, '\u003e'], [/>/g, '\u003E'],
[/"/g, '\u0022'], [/"/g, '\u0022'],
[/'/g, '\u0027'] [/'/g, '\u0027']
]; ];
// sanitizes potentially dangerous characters // sanitizes potentially dangerous characters
function escape(info, options, escapeOptions) { function escape (info, options, escapeOptions) {
var tagIDKeyName = options.tagIDKeyName; var tagIDKeyName = options.tagIDKeyName;
var doEscape = escapeOptions.doEscape; if ( doEscape === void 0 ) doEscape = function (v) { return v; }; var doEscape = escapeOptions.doEscape; if ( doEscape === void 0 ) doEscape = function (v) { return v; };
var escaped = {}; var escaped = {};
@@ -596,7 +596,7 @@ function escape(info, options, escapeOptions) {
return escaped return escaped
} }
function arrayMerge(ref, target, source) { function arrayMerge (ref, target, source) {
var component = ref.component; var component = ref.component;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
var metaTemplateKeyName = ref.metaTemplateKeyName; var metaTemplateKeyName = ref.metaTemplateKeyName;
@@ -663,7 +663,7 @@ function arrayMerge(ref, target, source) {
return destination.concat(source) return destination.concat(source)
} }
function merge(target, source, options) { function merge (target, source, options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
// remove properties explicitly set to false so child components can // remove properties explicitly set to false so child components can
@@ -708,7 +708,7 @@ function merge(target, source, options) {
* @param {Object} [result={}] - result so far * @param {Object} [result={}] - result so far
* @return {Object} result - final aggregated result * @return {Object} result - final aggregated result
*/ */
function getComponentOption(options, component, result) { function getComponentOption (options, component, result) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if ( result === void 0 ) result = {}; if ( result === void 0 ) result = {};
@@ -778,7 +778,7 @@ function getComponentOption(options, component, result) {
* @param {Object} component - the Vue instance to get meta info from * @param {Object} component - the Vue instance to get meta info from
* @return {Object} - returned meta info * @return {Object} - returned meta info
*/ */
function getMetaInfo(options, component, escapeSequences) { function getMetaInfo (options, component, escapeSequences) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if ( escapeSequences === void 0 ) escapeSequences = []; if ( escapeSequences === void 0 ) escapeSequences = [];
@@ -836,7 +836,7 @@ function getMetaInfo(options, component, escapeSequences) {
* @param {Object} attrs - the new document html attributes * @param {Object} attrs - the new document html attributes
* @param {HTMLElement} tag - the HTMLElement tag to update with new attrs * @param {HTMLElement} tag - the HTMLElement tag to update with new attrs
*/ */
function updateAttribute(ref, attrs, tag) { function updateAttribute (ref, attrs, tag) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
@@ -881,7 +881,7 @@ function updateAttribute(ref, attrs, tag) {
* *
* @param {String} title - the new title of the document * @param {String} title - the new title of the document
*/ */
function updateTitle(title) { function updateTitle (title) {
if (title === undefined) { if (title === undefined) {
return return
} }
@@ -897,7 +897,7 @@ function updateTitle(title) {
* @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base * @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base
* @return {Object} - a representation of what tags changed * @return {Object} - a representation of what tags changed
*/ */
function updateTag(appId, ref, type, tags, headTag, bodyTag) { function updateTag (appId, ref, type, tags, headTag, bodyTag) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
@@ -943,7 +943,13 @@ function updateTag(appId, ref, type, tags, headTag, bodyTag) {
var _attr = includes(dataAttributes, attr) var _attr = includes(dataAttributes, attr)
? ("data-" + attr) ? ("data-" + attr)
: attr; : attr;
var value = isUndefined(tag[attr]) || includes(booleanHtmlAttributes, attr) ? '' : tag[attr];
var isBooleanAttribute = includes(booleanHtmlAttributes, attr);
if (isBooleanAttribute && !tag[attr]) {
continue
}
var value = isBooleanAttribute ? '' : tag[attr];
newElement.setAttribute(_attr, value); newElement.setAttribute(_attr, value);
} }
} }
@@ -977,7 +983,7 @@ function updateTag(appId, ref, type, tags, headTag, bodyTag) {
return { oldTags: oldTags, newTags: newTags } return { oldTags: oldTags, newTags: newTags }
} }
function getTag(tags, tag) { function getTag (tags, tag) {
if (!tags[tag]) { if (!tags[tag]) {
tags[tag] = document.getElementsByTagName(tag)[0]; tags[tag] = document.getElementsByTagName(tag)[0];
} }
@@ -990,7 +996,7 @@ function getTag(tags, tag) {
* *
* @param {Object} newInfo - the meta info to update to * @param {Object} newInfo - the meta info to update to
*/ */
function updateClientMetaInfo(appId, options, newInfo) { function updateClientMetaInfo (appId, options, newInfo) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
var ssrAttribute = options.ssrAttribute; var ssrAttribute = options.ssrAttribute;
@@ -1054,7 +1060,7 @@ function updateClientMetaInfo(appId, options, newInfo) {
return { addedTags: addedTags, removedTags: removedTags } return { addedTags: addedTags, removedTags: removedTags }
} }
function _refresh(options) { function _refresh (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
/** /**
@@ -1067,7 +1073,7 @@ function _refresh(options) {
* *
* @return {Object} - new meta info * @return {Object} - new meta info
*/ */
return function refresh() { return function refresh () {
var metaInfo = getMetaInfo(options, this.$root, clientSequences); var metaInfo = getMetaInfo(options, this.$root, clientSequences);
var appId = this.$root._vueMeta.appId; var appId = this.$root._vueMeta.appId;
@@ -1088,12 +1094,12 @@ function _refresh(options) {
* @param {Object} data - the attributes to generate * @param {Object} data - the attributes to generate
* @return {Object} - the attribute generator * @return {Object} - the attribute generator
*/ */
function attributeGenerator(ref, type, data) { function attributeGenerator (ref, type, data) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
return { return {
text: function text() { text: function text () {
var attributeStr = ''; var attributeStr = '';
var watchedAttrs = []; var watchedAttrs = [];
@@ -1122,12 +1128,12 @@ function attributeGenerator(ref, type, data) {
* @param {String} data - the title text * @param {String} data - the title text
* @return {Object} - the title generator * @return {Object} - the title generator
*/ */
function titleGenerator(appId, ref, type, data) { function titleGenerator (appId, ref, type, data) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
return { return {
text: function text() { text: function text () {
return ("<" + type + ">" + data + "</" + type + ">") return ("<" + type + ">" + data + "</" + type + ">")
} }
} }
@@ -1140,13 +1146,13 @@ function titleGenerator(appId, ref, type, data) {
* @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base * @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base
* @return {Object} - the tag generator * @return {Object} - the tag generator
*/ */
function tagGenerator(appId, ref, type, tags) { function tagGenerator (appId, ref, type, tags) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
return { return {
text: function text(ref) { text: function text (ref) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var body = ref.body; if ( body === void 0 ) body = false; var body = ref.body; if ( body === void 0 ) body = false;
@@ -1175,7 +1181,12 @@ function tagGenerator(appId, ref, type, tags) {
prefix = 'data-'; prefix = 'data-';
} }
return isUndefined(tag[attr]) || booleanHtmlAttributes.includes(attr) var isBooleanAttr = booleanHtmlAttributes.includes(attr);
if (isBooleanAttr && !tag[attr]) {
return attrsStr
}
return isBooleanAttr
? (attrsStr + " " + prefix + attr) ? (attrsStr + " " + prefix + attr)
: (attrsStr + " " + prefix + attr + "=\"" + (tag[attr]) + "\"") : (attrsStr + " " + prefix + attr + "=\"" + (tag[attr]) + "\"")
}, ''); }, '');
@@ -1211,7 +1222,7 @@ function tagGenerator(appId, ref, type, tags) {
* @return {Object} - the new injector * @return {Object} - the new injector
*/ */
function generateServerInjector(appId, options, type, data) { function generateServerInjector (appId, options, type, data) {
if (type === 'title') { if (type === 'title') {
return titleGenerator(appId, options, type, data) return titleGenerator(appId, options, type, data)
} }
@@ -1223,7 +1234,7 @@ function generateServerInjector(appId, options, type, data) {
return tagGenerator(appId, options, type, data) return tagGenerator(appId, options, type, data)
} }
function _inject(options) { function _inject (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
/** /**
@@ -1233,7 +1244,7 @@ function _inject(options) {
* @this {Object} - Vue instance - ideally the root component * @this {Object} - Vue instance - ideally the root component
* @return {Object} - server meta info with `toString` methods * @return {Object} - server meta info with `toString` methods
*/ */
return function inject() { return function inject () {
// get meta info with sensible defaults // get meta info with sensible defaults
var metaInfo = getMetaInfo(options, this.$root, serverSequences); var metaInfo = getMetaInfo(options, this.$root, serverSequences);
@@ -1248,7 +1259,7 @@ function _inject(options) {
} }
} }
function _$meta(options) { function _$meta (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
var _refresh$1 = _refresh(options); var _refresh$1 = _refresh(options);
@@ -1259,7 +1270,7 @@ function _$meta(options) {
* @this {Object} - the Vue instance (a root component) * @this {Object} - the Vue instance (a root component)
* @return {Object} - injector * @return {Object} - injector
*/ */
return function $meta() { return function $meta () {
return { return {
getOptions: function () { return getOptions(options); }, getOptions: function () { return getOptions(options); },
refresh: _refresh$1.bind(this), refresh: _refresh$1.bind(this),
@@ -1274,7 +1285,7 @@ function _$meta(options) {
* Plugin install function. * Plugin install function.
* @param {Function} Vue - the Vue constructor. * @param {Function} Vue - the Vue constructor.
*/ */
function install(Vue, options) { function install (Vue, options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if (Vue.__vuemeta_installed) { if (Vue.__vuemeta_installed) {
+143 -150
View File
@@ -1,5 +1,5 @@
/** /**
* vue-meta v2.0.4 * vue-meta v2.0.5
* (c) 2019 * (c) 2019
* - Declan de Wet * - Declan de Wet
* - Sébastien Chopin (@Atinux) * - Sébastien Chopin (@Atinux)
@@ -13,12 +13,12 @@
(global = global || self, global.VueMeta = factory()); (global = global || self, global.VueMeta = factory());
}(this, function () { 'use strict'; }(this, function () { 'use strict';
var version = "2.0.4"; var version = "2.0.5";
// store an id to keep track of DOM updates // store an id to keep track of DOM updates
var batchId = null; var batchId = null;
function triggerUpdate(vm, hookName) { function triggerUpdate (vm, hookName) {
// if an update was triggered during initialization or when an update was triggered by the // if an update was triggered during initialization or when an update was triggered by the
// metaInfo watcher, set initialized to null // metaInfo watcher, set initialized to null
// then we keep falsy value but know we need to run a triggerUpdate after initialization // then we keep falsy value but know we need to run a triggerUpdate after initialization
@@ -39,7 +39,7 @@
* @param {Function} callback - the update to perform * @param {Function} callback - the update to perform
* @return {Number} id - a new ID * @return {Number} id - a new ID
*/ */
function batchUpdate(callback, timeout) { function batchUpdate (callback, timeout) {
if ( timeout === void 0 ) timeout = 10; if ( timeout === void 0 ) timeout = 10;
clearTimeout(batchId); clearTimeout(batchId);
@@ -56,27 +56,27 @@
* @param {any} arg - the object to check * @param {any} arg - the object to check
* @return {Boolean} - true if `arg` is an array * @return {Boolean} - true if `arg` is an array
*/ */
function isArray(arg) { function isArray (arg) {
return Array.isArray(arg) return Array.isArray(arg)
} }
function isUndefined(arg) { function isUndefined (arg) {
return typeof arg === 'undefined' return typeof arg === 'undefined'
} }
function isObject(arg) { function isObject (arg) {
return typeof arg === 'object' return typeof arg === 'object'
} }
function isFunction(arg) { function isFunction (arg) {
return typeof arg === 'function' return typeof arg === 'function'
} }
function isString(arg) { function isString (arg) {
return typeof arg === 'string' return typeof arg === 'string'
} }
function ensureIsArray(arg, key) { function ensureIsArray (arg, key) {
if (!key || !isObject(arg)) { if (!key || !isObject(arg)) {
return isArray(arg) ? arg : [] return isArray(arg) ? arg : []
} }
@@ -87,27 +87,27 @@
return arg return arg
} }
function ensuredPush(object, key, el) { function ensuredPush (object, key, el) {
ensureIsArray(object, key); ensureIsArray(object, key);
object[key].push(el); object[key].push(el);
} }
// Vue $root instance has a _vueMeta object property, otherwise its a boolean true // Vue $root instance has a _vueMeta object property, otherwise its a boolean true
function hasMetaInfo(vm) { function hasMetaInfo (vm) {
if ( vm === void 0 ) vm = this; if ( vm === void 0 ) vm = this;
return vm && (vm._vueMeta === true || isObject(vm._vueMeta)) return vm && (vm._vueMeta === true || isObject(vm._vueMeta))
} }
// a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has // a component is in a metaInfo branch when itself has meta info or one of its (grand-)children has
function inMetaInfoBranch(vm) { function inMetaInfoBranch (vm) {
if ( vm === void 0 ) vm = this; if ( vm === void 0 ) vm = this;
return vm && !isUndefined(vm._vueMeta) return vm && !isUndefined(vm._vueMeta)
} }
function addNavGuards(vm) { function addNavGuards (vm) {
// return when nav guards already added or no router exists // return when nav guards already added or no router exists
if (vm.$root._vueMeta.navGuards || !vm.$root.$router) { if (vm.$root._vueMeta.navGuards || !vm.$root.$router) {
/* istanbul ignore next */ /* istanbul ignore next */
@@ -135,18 +135,18 @@
var appId = 1; var appId = 1;
function createMixin(Vue, options) { function createMixin (Vue, options) {
// for which Vue lifecycle hooks should the metaInfo be refreshed // for which Vue lifecycle hooks should the metaInfo be refreshed
var updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount']; var updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount'];
// watch for client side component updates // watch for client side component updates
return { return {
beforeCreate: function beforeCreate() { beforeCreate: function beforeCreate () {
var this$1 = this; var this$1 = this;
Object.defineProperty(this, '_hasMetaInfo', { Object.defineProperty(this, '_hasMetaInfo', {
configurable: true, configurable: true,
get: function get() { get: function get () {
// Show deprecation warning once when devtools enabled // Show deprecation warning once when devtools enabled
if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) { if (Vue.config.devtools && !this.$root._vueMeta.hasMetaInfoDeprecationWarningShown) {
console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console console.warn('VueMeta DeprecationWarning: _hasMetaInfo has been deprecated and will be removed in a future version. Please use hasMetaInfo(vm) instead'); // eslint-disable-line no-console
@@ -210,7 +210,7 @@
ensuredPush(this.$options, 'beforeMount', function () { ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr' // if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported // only one SSR app per page is supported
if (this$1.$root.$el && this$1.$root.$el.hasAttribute('data-server-rendered')) { if (this$1.$root.$el && this$1.$root.$el.hasAttribute && this$1.$root.$el.hasAttribute('data-server-rendered')) {
this$1.$root._vueMeta.appId = 'ssr'; this$1.$root._vueMeta.appId = 'ssr';
} }
}); });
@@ -417,7 +417,7 @@
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
var showWarningNotSupported = function () { return console.warn('This vue app/component has no vue-meta configuration'); }; var showWarningNotSupported = function () { return console.warn('This vue app/component has no vue-meta configuration'); };
function setOptions(options) { function setOptions (options) {
// combine options // combine options
options = isObject(options) ? options : {}; options = isObject(options) ? options : {};
@@ -430,7 +430,7 @@
return options return options
} }
function getOptions(options) { function getOptions (options) {
var optionsCopy = {}; var optionsCopy = {};
for (var key in options) { for (var key in options) {
optionsCopy[key] = options[key]; optionsCopy[key] = options[key];
@@ -438,7 +438,7 @@
return optionsCopy return optionsCopy
} }
function pause(refresh) { function pause (refresh) {
if ( refresh === void 0 ) refresh = true; if ( refresh === void 0 ) refresh = true;
this.$root._vueMeta.paused = true; this.$root._vueMeta.paused = true;
@@ -446,7 +446,7 @@
return function () { return resume(refresh); } return function () { return resume(refresh); }
} }
function resume(refresh) { function resume (refresh) {
if ( refresh === void 0 ) refresh = true; if ( refresh === void 0 ) refresh = true;
this.$root._vueMeta.paused = false; this.$root._vueMeta.paused = false;
@@ -456,7 +456,7 @@
} }
} }
function applyTemplate(ref, headObject, template, chunk) { function applyTemplate (ref, headObject, template, chunk) {
var component = ref.component; var component = ref.component;
var metaTemplateKeyName = ref.metaTemplateKeyName; var metaTemplateKeyName = ref.metaTemplateKeyName;
var contentKeyName = ref.contentKeyName; var contentKeyName = ref.contentKeyName;
@@ -491,7 +491,7 @@
* files in server/ still use normal js function * files in server/ still use normal js function
*/ */
function findIndex(array, predicate) { function findIndex (array, predicate) {
var arguments$1 = arguments; var arguments$1 = arguments;
if ( !Array.prototype.findIndex) { if ( !Array.prototype.findIndex) {
@@ -506,14 +506,14 @@
return array.findIndex(predicate, arguments[2]) return array.findIndex(predicate, arguments[2])
} }
function toArray(arg) { function toArray (arg) {
if ( !Array.from) { if ( !Array.from) {
return Array.prototype.slice.call(arg) return Array.prototype.slice.call(arg)
} }
return Array.from(arg) return Array.from(arg)
} }
function includes(array, value) { function includes (array, value) {
if ( !Array.prototype.includes) { if ( !Array.prototype.includes) {
for (var idx in array) { for (var idx in array) {
if (array[idx] === value) { if (array[idx] === value) {
@@ -528,14 +528,14 @@
var clientSequences = [ var clientSequences = [
[/&/g, '\u0026'], [/&/g, '\u0026'],
[/</g, '\u003c'], [/</g, '\u003C'],
[/>/g, '\u003e'], [/>/g, '\u003E'],
[/"/g, '\u0022'], [/"/g, '\u0022'],
[/'/g, '\u0027'] [/'/g, '\u0027']
]; ];
// sanitizes potentially dangerous characters // sanitizes potentially dangerous characters
function escape(info, options, escapeOptions) { function escape (info, options, escapeOptions) {
var tagIDKeyName = options.tagIDKeyName; var tagIDKeyName = options.tagIDKeyName;
var doEscape = escapeOptions.doEscape; if ( doEscape === void 0 ) doEscape = function (v) { return v; }; var doEscape = escapeOptions.doEscape; if ( doEscape === void 0 ) doEscape = function (v) { return v; };
var escaped = {}; var escaped = {};
@@ -585,130 +585,117 @@
return escaped return escaped
} }
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var isMergeableObject = function isMergeableObject(value) {
return isNonNullObject(value)
&& !isSpecial(value)
};
function createCommonjsModule(fn, module) { function isNonNullObject(value) {
return module = { exports: {} }, fn(module, module.exports), module.exports; return !!value && typeof value === 'object'
} }
var umd = createCommonjsModule(function (module, exports) { function isSpecial(value) {
(function (global, factory) { var stringValue = Object.prototype.toString.call(value);
module.exports = factory() ;
}(commonjsGlobal, function () {
var isMergeableObject = function isMergeableObject(value) {
return isNonNullObject(value)
&& !isSpecial(value)
};
function isNonNullObject(value) { return stringValue === '[object RegExp]'
return !!value && typeof value === 'object' || stringValue === '[object Date]'
|| isReactElement(value)
}
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
function isReactElement(value) {
return value.$$typeof === REACT_ELEMENT_TYPE
}
function emptyTarget(val) {
return Array.isArray(val) ? [] : {}
}
function cloneUnlessOtherwiseSpecified(value, options) {
return (options.clone !== false && options.isMergeableObject(value))
? deepmerge(emptyTarget(value), value, options)
: value
}
function defaultArrayMerge(target, source, options) {
return target.concat(source).map(function(element) {
return cloneUnlessOtherwiseSpecified(element, options)
})
}
function getMergeFunction(key, options) {
if (!options.customMerge) {
return deepmerge
} }
var customMerge = options.customMerge(key);
return typeof customMerge === 'function' ? customMerge : deepmerge
}
function isSpecial(value) { function getEnumerableOwnPropertySymbols(target) {
var stringValue = Object.prototype.toString.call(value); return Object.getOwnPropertySymbols
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
return stringValue === '[object RegExp]' return target.propertyIsEnumerable(symbol)
|| stringValue === '[object Date]'
|| isReactElement(value)
}
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
function isReactElement(value) {
return value.$$typeof === REACT_ELEMENT_TYPE
}
function emptyTarget(val) {
return Array.isArray(val) ? [] : {}
}
function cloneUnlessOtherwiseSpecified(value, options) {
return (options.clone !== false && options.isMergeableObject(value))
? deepmerge(emptyTarget(value), value, options)
: value
}
function defaultArrayMerge(target, source, options) {
return target.concat(source).map(function(element) {
return cloneUnlessOtherwiseSpecified(element, options)
}) })
} : []
}
function getMergeFunction(key, options) { function getKeys(target) {
if (!options.customMerge) { return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
return deepmerge }
}
var customMerge = options.customMerge(key);
return typeof customMerge === 'function' ? customMerge : deepmerge
}
function getEnumerableOwnPropertySymbols(target) { function mergeObject(target, source, options) {
return Object.getOwnPropertySymbols var destination = {};
? Object.getOwnPropertySymbols(target).filter(function(symbol) { if (options.isMergeableObject(target)) {
return target.propertyIsEnumerable(symbol) getKeys(target).forEach(function(key) {
}) destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
: []
}
function getKeys(target) {
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
}
function mergeObject(target, source, options) {
var destination = {};
if (options.isMergeableObject(target)) {
getKeys(target).forEach(function(key) {
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
});
}
getKeys(source).forEach(function(key) {
if (!options.isMergeableObject(source[key]) || !target[key]) {
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
} else {
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
}
}); });
return destination
} }
getKeys(source).forEach(function(key) {
function deepmerge(target, source, options) { if (!options.isMergeableObject(source[key]) || !target[key]) {
options = options || {}; destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
var sourceIsArray = Array.isArray(source);
var targetIsArray = Array.isArray(target);
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
if (!sourceAndTargetTypesMatch) {
return cloneUnlessOtherwiseSpecified(source, options)
} else if (sourceIsArray) {
return options.arrayMerge(target, source, options)
} else { } else {
return mergeObject(target, source, options) destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
} }
});
return destination
}
function deepmerge(target, source, options) {
options = options || {};
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
var sourceIsArray = Array.isArray(source);
var targetIsArray = Array.isArray(target);
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
if (!sourceAndTargetTypesMatch) {
return cloneUnlessOtherwiseSpecified(source, options)
} else if (sourceIsArray) {
return options.arrayMerge(target, source, options)
} else {
return mergeObject(target, source, options)
}
}
deepmerge.all = function deepmergeAll(array, options) {
if (!Array.isArray(array)) {
throw new Error('first argument should be an array')
} }
deepmerge.all = function deepmergeAll(array, options) { return array.reduce(function(prev, next) {
if (!Array.isArray(array)) { return deepmerge(prev, next, options)
throw new Error('first argument should be an array') }, {})
} };
return array.reduce(function(prev, next) { var deepmerge_1 = deepmerge;
return deepmerge(prev, next, options)
}, {})
};
var deepmerge_1 = deepmerge; var cjs = deepmerge_1;
return deepmerge_1; function arrayMerge (ref, target, source) {
}));
});
function arrayMerge(ref, target, source) {
var component = ref.component; var component = ref.component;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
var metaTemplateKeyName = ref.metaTemplateKeyName; var metaTemplateKeyName = ref.metaTemplateKeyName;
@@ -775,7 +762,7 @@
return destination.concat(source) return destination.concat(source)
} }
function merge(target, source, options) { function merge (target, source, options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
// remove properties explicitly set to false so child components can // remove properties explicitly set to false so child components can
@@ -801,7 +788,7 @@
} }
}); });
return umd(target, source, { return cjs(target, source, {
arrayMerge: function (t, s) { return arrayMerge(options, t, s); } arrayMerge: function (t, s) { return arrayMerge(options, t, s); }
}) })
} }
@@ -820,7 +807,7 @@
* @param {Object} [result={}] - result so far * @param {Object} [result={}] - result so far
* @return {Object} result - final aggregated result * @return {Object} result - final aggregated result
*/ */
function getComponentOption(options, component, result) { function getComponentOption (options, component, result) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if ( result === void 0 ) result = {}; if ( result === void 0 ) result = {};
@@ -890,7 +877,7 @@
* @param {Object} component - the Vue instance to get meta info from * @param {Object} component - the Vue instance to get meta info from
* @return {Object} - returned meta info * @return {Object} - returned meta info
*/ */
function getMetaInfo(options, component, escapeSequences) { function getMetaInfo (options, component, escapeSequences) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if ( escapeSequences === void 0 ) escapeSequences = []; if ( escapeSequences === void 0 ) escapeSequences = [];
@@ -948,7 +935,7 @@
* @param {Object} attrs - the new document html attributes * @param {Object} attrs - the new document html attributes
* @param {HTMLElement} tag - the HTMLElement tag to update with new attrs * @param {HTMLElement} tag - the HTMLElement tag to update with new attrs
*/ */
function updateAttribute(ref, attrs, tag) { function updateAttribute (ref, attrs, tag) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
@@ -993,7 +980,7 @@
* *
* @param {String} title - the new title of the document * @param {String} title - the new title of the document
*/ */
function updateTitle(title) { function updateTitle (title) {
if (title === undefined) { if (title === undefined) {
return return
} }
@@ -1009,7 +996,7 @@
* @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base * @param {(Array<Object>|Object)} tags - an array of tag objects or a single object in case of base
* @return {Object} - a representation of what tags changed * @return {Object} - a representation of what tags changed
*/ */
function updateTag(appId, ref, type, tags, headTag, bodyTag) { function updateTag (appId, ref, type, tags, headTag, bodyTag) {
if ( ref === void 0 ) ref = {}; if ( ref === void 0 ) ref = {};
var attribute = ref.attribute; var attribute = ref.attribute;
var tagIDKeyName = ref.tagIDKeyName; var tagIDKeyName = ref.tagIDKeyName;
@@ -1055,7 +1042,13 @@
var _attr = includes(dataAttributes, attr) var _attr = includes(dataAttributes, attr)
? ("data-" + attr) ? ("data-" + attr)
: attr; : attr;
var value = isUndefined(tag[attr]) || includes(booleanHtmlAttributes, attr) ? '' : tag[attr];
var isBooleanAttribute = includes(booleanHtmlAttributes, attr);
if (isBooleanAttribute && !tag[attr]) {
continue
}
var value = isBooleanAttribute ? '' : tag[attr];
newElement.setAttribute(_attr, value); newElement.setAttribute(_attr, value);
} }
} }
@@ -1089,7 +1082,7 @@
return { oldTags: oldTags, newTags: newTags } return { oldTags: oldTags, newTags: newTags }
} }
function getTag(tags, tag) { function getTag (tags, tag) {
if (!tags[tag]) { if (!tags[tag]) {
tags[tag] = document.getElementsByTagName(tag)[0]; tags[tag] = document.getElementsByTagName(tag)[0];
} }
@@ -1102,7 +1095,7 @@
* *
* @param {Object} newInfo - the meta info to update to * @param {Object} newInfo - the meta info to update to
*/ */
function updateClientMetaInfo(appId, options, newInfo) { function updateClientMetaInfo (appId, options, newInfo) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
var ssrAttribute = options.ssrAttribute; var ssrAttribute = options.ssrAttribute;
@@ -1166,7 +1159,7 @@
return { addedTags: addedTags, removedTags: removedTags } return { addedTags: addedTags, removedTags: removedTags }
} }
function _refresh(options) { function _refresh (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
/** /**
@@ -1179,7 +1172,7 @@
* *
* @return {Object} - new meta info * @return {Object} - new meta info
*/ */
return function refresh() { return function refresh () {
var metaInfo = getMetaInfo(options, this.$root, clientSequences); var metaInfo = getMetaInfo(options, this.$root, clientSequences);
var appId = this.$root._vueMeta.appId; var appId = this.$root._vueMeta.appId;
@@ -1193,7 +1186,7 @@
} }
} }
function _$meta(options) { function _$meta (options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
var _refresh$1 = _refresh(options); var _refresh$1 = _refresh(options);
@@ -1204,7 +1197,7 @@
* @this {Object} - the Vue instance (a root component) * @this {Object} - the Vue instance (a root component)
* @return {Object} - injector * @return {Object} - injector
*/ */
return function $meta() { return function $meta () {
if (!this.$root._vueMeta) { if (!this.$root._vueMeta) {
return { return {
getOptions: showWarningNotSupported, getOptions: showWarningNotSupported,
@@ -1229,7 +1222,7 @@
* Plugin install function. * Plugin install function.
* @param {Function} Vue - the Vue constructor. * @param {Function} Vue - the Vue constructor.
*/ */
function install(Vue, options) { function install (Vue, options) {
if ( options === void 0 ) options = {}; if ( options === void 0 ) options = {};
if (Vue.__vuemeta_installed) { if (Vue.__vuemeta_installed) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "vue-meta", "name": "vue-meta",
"version": "2.0.4", "version": "2.0.5",
"description": "Manage HTML metadata in Vue.js components with ssr support", "description": "Manage HTML metadata in Vue.js components with ssr support",
"keywords": [ "keywords": [
"attribute", "attribute",