2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-05-17 05:09:38 +03:00

chore(release): 2.2.2

This commit is contained in:
pimlie
2019-08-30 16:19:52 +00:00
parent 00c0939abe
commit d0baf34180
8 changed files with 523 additions and 483 deletions
+8
View File
@@ -2,6 +2,14 @@
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.2.2](https://github.com/nuxt/vue-meta/compare/v2.2.1...v2.2.2) (2019-08-30)
### Bug Fixes
* workaround for memoryleak in destroyed hook ([ec7b1fb](https://github.com/nuxt/vue-meta/commit/ec7b1fb))
* **types:** add "content" property to MetaPropertyEquiv and remove "name" ([#436](https://github.com/nuxt/vue-meta/issues/436)) ([4384f44](https://github.com/nuxt/vue-meta/commit/4384f44))
### [2.2.1](https://github.com/nuxt/vue-meta/compare/v2.2.0...v2.2.1) (2019-08-04)
+128 -120
View File
@@ -1,5 +1,5 @@
/**
* vue-meta v2.2.1
* vue-meta v2.2.2
* (c) 2019
* - Declan de Wet
* - Sébastien Chopin (@Atinux)
@@ -13,7 +13,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
var deepmerge = _interopDefault(require('deepmerge'));
var version = "2.2.1";
var version = "2.2.2";
// store an id to keep track of DOM updates
var batchId = null;
@@ -240,137 +240,145 @@ function createMixin(Vue, options) {
// _vnode is used to know that it's attached to a real component
// useful if we use some mixin to add some meta tags (like nuxt-i18n)
if (!isUndefined(this.$options[options.keyName]) && this.$options[options.keyName] !== null) {
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (isUndefined(this.$options[options.keyName]) || this.$options[options.keyName] === null) {
return;
}
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
triggerUpdate(this, 'watcher');
});
});
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
_this.__metaInfo = undefined;
triggerUpdate(_this, 'watcher');
});
}); // re-render meta data when returning from a child component to parent
ensuredPush(this.$options, 'destroyed', function () {
// Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this.$el && _this.$el.offsetParent !== null) {
/* istanbul ignore next line */
return;
}
clearInterval(interval);
if (!_this.$parent) {
/* istanbul ignore next line */
return;
}
triggerUpdate(_this, 'destroyed');
}, 50);
});
}
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (this.$isServer) {
return;
} // no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
});
});
},
// TODO: move back into beforeCreate when Vue issue is resolved
destroyed: function destroyed() {
var _this3 = this;
// do not trigger refresh:
// - on the server side
// - when the component doesnt have a parent
// - doesnt have metaInfo defined
if (this.$isServer || !this.$parent || !hasMetaInfo(this)) {
return;
} // Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this3.$el && _this3.$el.offsetParent !== null) {
return;
}
clearInterval(interval);
triggerUpdate(_this3, 'destroyed');
}, 50);
}
};
}
+128 -120
View File
@@ -1,5 +1,5 @@
/**
* vue-meta v2.2.1
* vue-meta v2.2.2
* (c) 2019
* - Declan de Wet
* - Sébastien Chopin (@Atinux)
@@ -9,7 +9,7 @@
import deepmerge from 'deepmerge';
var version = "2.2.1";
var version = "2.2.2";
// store an id to keep track of DOM updates
var batchId = null;
@@ -219,137 +219,145 @@ function createMixin(Vue, options) {
// _vnode is used to know that it's attached to a real component
// useful if we use some mixin to add some meta tags (like nuxt-i18n)
if (!isUndefined(this.$options[options.keyName]) && this.$options[options.keyName] !== null) {
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (isUndefined(this.$options[options.keyName]) || this.$options[options.keyName] === null) {
return;
}
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
triggerUpdate(this, 'watcher');
});
});
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
_this.__metaInfo = undefined;
triggerUpdate(_this, 'watcher');
});
}); // re-render meta data when returning from a child component to parent
ensuredPush(this.$options, 'destroyed', function () {
// Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this.$el && _this.$el.offsetParent !== null) {
/* istanbul ignore next line */
return;
}
clearInterval(interval);
if (!_this.$parent) {
/* istanbul ignore next line */
return;
}
triggerUpdate(_this, 'destroyed');
}, 50);
});
}
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (this.$isServer) {
return;
} // no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
});
});
},
// TODO: move back into beforeCreate when Vue issue is resolved
destroyed: function destroyed() {
var _this3 = this;
// do not trigger refresh:
// - on the server side
// - when the component doesnt have a parent
// - doesnt have metaInfo defined
if (this.$isServer || !this.$parent || !hasMetaInfo(this)) {
return;
} // Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this3.$el && _this3.$el.offsetParent !== null) {
return;
}
clearInterval(interval);
triggerUpdate(_this3, 'destroyed');
}, 50);
}
};
}
+1 -1
View File
File diff suppressed because one or more lines are too long
+128 -120
View File
@@ -1,5 +1,5 @@
/**
* vue-meta v2.2.1
* vue-meta v2.2.2
* (c) 2019
* - Declan de Wet
* - Sébastien Chopin (@Atinux)
@@ -9,7 +9,7 @@
import deepmerge from 'deepmerge';
var version = "2.2.1";
var version = "2.2.2";
// store an id to keep track of DOM updates
var batchId = null;
@@ -236,137 +236,145 @@ function createMixin(Vue, options) {
// _vnode is used to know that it's attached to a real component
// useful if we use some mixin to add some meta tags (like nuxt-i18n)
if (!isUndefined(this.$options[options.keyName]) && this.$options[options.keyName] !== null) {
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (isUndefined(this.$options[options.keyName]) || this.$options[options.keyName] === null) {
return;
}
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
triggerUpdate(this, 'watcher');
});
});
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
_this.__metaInfo = undefined;
triggerUpdate(_this, 'watcher');
});
}); // re-render meta data when returning from a child component to parent
ensuredPush(this.$options, 'destroyed', function () {
// Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this.$el && _this.$el.offsetParent !== null) {
/* istanbul ignore next line */
return;
}
clearInterval(interval);
if (!_this.$parent) {
/* istanbul ignore next line */
return;
}
triggerUpdate(_this, 'destroyed');
}, 50);
});
}
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (this.$isServer) {
return;
} // no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
});
});
},
// TODO: move back into beforeCreate when Vue issue is resolved
destroyed: function destroyed() {
var _this3 = this;
// do not trigger refresh:
// - on the server side
// - when the component doesnt have a parent
// - doesnt have metaInfo defined
if (this.$isServer || !this.$parent || !hasMetaInfo(this)) {
return;
} // Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this3.$el && _this3.$el.offsetParent !== null) {
return;
}
clearInterval(interval);
triggerUpdate(_this3, 'destroyed');
}, 50);
}
};
}
+128 -120
View File
@@ -1,5 +1,5 @@
/**
* vue-meta v2.2.1
* vue-meta v2.2.2
* (c) 2019
* - Declan de Wet
* - Sébastien Chopin (@Atinux)
@@ -13,7 +13,7 @@
(global = global || self, global.VueMeta = factory());
}(this, function () { 'use strict';
var version = "2.2.1";
var version = "2.2.2";
// store an id to keep track of DOM updates
var batchId = null;
@@ -223,137 +223,145 @@
// _vnode is used to know that it's attached to a real component
// useful if we use some mixin to add some meta tags (like nuxt-i18n)
if (!isUndefined(this.$options[options.keyName]) && this.$options[options.keyName] !== null) {
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (isUndefined(this.$options[options.keyName]) || this.$options[options.keyName] === null) {
return;
}
if (!this.$root._vueMeta) {
this.$root._vueMeta = {
appId: appId
};
appId++;
} // to speed up updates we keep track of branches which have a component with vue-meta info defined
// if _vueMeta = true it has info, if _vueMeta = false a child has info
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
if (!this._vueMeta) {
this._vueMeta = true;
var p = this.$parent;
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
while (p && p !== this.$root) {
if (isUndefined(p._vueMeta)) {
p._vueMeta = false;
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
triggerUpdate(this, 'watcher');
});
});
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
p = p.$parent;
}
} // coerce function-style metaInfo to a computed prop so we can observe
// it on creation
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (isFunction(this.$options[options.keyName])) {
if (!this.$options.computed) {
this.$options.computed = {};
}
this.$options.computed.$metaInfo = this.$options[options.keyName];
if (!this.$isServer) {
// no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
// if computed $metaInfo exists, watch it for updates & trigger a refresh
// when it changes (i.e. automatically handle async actions that affect metaInfo)
// credit for this suggestion goes to [Sébastien Chopin](https://github.com/Atinux)
ensuredPush(this.$options, 'created', function () {
_this.$watch('$metaInfo', function () {
_this.__metaInfo = undefined;
triggerUpdate(_this, 'watcher');
});
}); // re-render meta data when returning from a child component to parent
ensuredPush(this.$options, 'destroyed', function () {
// Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this.$el && _this.$el.offsetParent !== null) {
/* istanbul ignore next line */
return;
}
clearInterval(interval);
if (!_this.$parent) {
/* istanbul ignore next line */
return;
}
triggerUpdate(_this, 'destroyed');
}, 50);
});
}
}
} // force an initial refresh on page load and prevent other lifecycleHooks
// to triggerUpdate until this initial refresh is finished
// this is to make sure that when a page is opened in an inactive tab which
// has throttled rAF/timers we still immediately set the page title
if (isUndefined(this.$root._vueMeta.initialized)) {
this.$root._vueMeta.initialized = this.$isServer;
if (!this.$root._vueMeta.initialized) {
ensuredPush(this.$options, 'beforeMount', function () {
// if this Vue-app was server rendered, set the appId to 'ssr'
// only one SSR app per page is supported
if (_this.$root.$el && _this.$root.$el.hasAttribute && _this.$root.$el.hasAttribute('data-server-rendered')) {
_this.$root._vueMeta.appId = options.ssrAppId;
}
}); // we use the mounted hook here as on page load
ensuredPush(this.$options, 'mounted', function () {
if (!_this.$root._vueMeta.initialized) {
// used in triggerUpdate to check if a change was triggered
// during initialization
_this.$root._vueMeta.initializing = true; // refresh meta in nextTick so all child components have loaded
_this.$nextTick(function () {
var _this2 = this;
var _this$$root$$meta$ref = this.$root.$meta().refresh(),
tags = _this$$root$$meta$ref.tags,
metaInfo = _this$$root$$meta$ref.metaInfo; // After ssr hydration (identifier by tags === false) check
// if initialized was set to null in triggerUpdate. That'd mean
// that during initilazation changes where triggered which need
// to be applied OR a metaInfo watcher was triggered before the
// current hook was called
// (during initialization all changes are blocked)
if (tags === false && this.$root._vueMeta.initialized === null) {
this.$nextTick(function () {
return triggerUpdate(_this2, 'initializing');
});
}
this.$root._vueMeta.initialized = true;
delete this.$root._vueMeta.initializing; // add the navigation guards if they havent been added yet
// they are needed for the afterNavigation callback
if (!options.refreshOnceOnNavigation && metaInfo.afterNavigation) {
addNavGuards(this);
}
});
}
}); // add the navigation guards if requested
if (options.refreshOnceOnNavigation) {
addNavGuards(this);
}
}
} // do not trigger refresh on the server side
if (this.$isServer) {
return;
} // no need to add this hooks on server side
updateOnLifecycleHook.forEach(function (lifecycleHook) {
ensuredPush(_this.$options, lifecycleHook, function () {
return triggerUpdate(_this, lifecycleHook);
});
});
},
// TODO: move back into beforeCreate when Vue issue is resolved
destroyed: function destroyed() {
var _this3 = this;
// do not trigger refresh:
// - on the server side
// - when the component doesnt have a parent
// - doesnt have metaInfo defined
if (this.$isServer || !this.$parent || !hasMetaInfo(this)) {
return;
} // Wait that element is hidden before refreshing meta tags (to support animations)
var interval = setInterval(function () {
if (_this3.$el && _this3.$el.offsetParent !== null) {
return;
}
clearInterval(interval);
triggerUpdate(_this3, 'destroyed');
}, 50);
}
};
}
+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",
"version": "2.2.1",
"version": "2.2.2",
"description": "Manage HTML metadata in Vue.js components with ssr support",
"keywords": [
"attribute",