mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-25 09:00:33 +03:00
chore(release): 2.2.0
This commit is contained in:
@@ -2,6 +2,39 @@
|
|||||||
|
|
||||||
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.2.0](https://github.com/nuxt/vue-meta/compare/v2.0.3...v2.2.0) (2019-07-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add warning for v1 boolean attribute syntax ([bfeab17](https://github.com/nuxt/vue-meta/commit/bfeab17))
|
||||||
|
* also use ssrAppId for client update ([50c0509](https://github.com/nuxt/vue-meta/commit/50c0509))
|
||||||
|
* babel config for rollup ([71b2d52](https://github.com/nuxt/vue-meta/commit/71b2d52))
|
||||||
|
* don't generate <title> tag if metaInfo.title is null or false ([#409](https://github.com/nuxt/vue-meta/issues/409)) ([39ef287](https://github.com/nuxt/vue-meta/commit/39ef287))
|
||||||
|
* 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))
|
||||||
|
* dont update title on client with falsy value except empty string ([6efcdf1](https://github.com/nuxt/vue-meta/commit/6efcdf1))
|
||||||
|
* 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))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add option for prepending (no)script to body ([#410](https://github.com/nuxt/vue-meta/issues/410)) ([05163a7](https://github.com/nuxt/vue-meta/commit/05163a7))
|
||||||
|
* auto add ssrAttribute to htmlAttrs ([9cf6d32](https://github.com/nuxt/vue-meta/commit/9cf6d32))
|
||||||
|
* enable onload callbacks ([#414](https://github.com/nuxt/vue-meta/issues/414)) ([fc71e1f](https://github.com/nuxt/vue-meta/commit/fc71e1f))
|
||||||
|
* make ssr app id configurable ([b0c85e5](https://github.com/nuxt/vue-meta/commit/b0c85e5))
|
||||||
|
* support generating tags directly from metaInfo object ([cb2758e](https://github.com/nuxt/vue-meta/commit/cb2758e))
|
||||||
|
* support json content (without disabling sanitizers) ([#415](https://github.com/nuxt/vue-meta/issues/415)) ([51fe6ea](https://github.com/nuxt/vue-meta/commit/51fe6ea))
|
||||||
|
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
|
||||||
|
* enable all getMetaInfo tests again ([24d7fee](https://github.com/nuxt/vue-meta/commit/24d7fee))
|
||||||
|
* update browser config ([8c35863](https://github.com/nuxt/vue-meta/commit/8c35863))
|
||||||
|
* use build/dist for e2e testing ([#421](https://github.com/nuxt/vue-meta/issues/421)) ([0bf0ceb](https://github.com/nuxt/vue-meta/commit/0bf0ceb))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### [2.1.1](https://github.com/nuxt/vue-meta/compare/v2.0.3...v2.1.1) (2019-07-26)
|
### [2.1.1](https://github.com/nuxt/vue-meta/compare/v2.0.3...v2.1.1) (2019-07-26)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Vendored
+176
-290
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v2.1.1
|
* vue-meta v2.2.0
|
||||||
* (c) 2019
|
* (c) 2019
|
||||||
* - Declan de Wet
|
* - Declan de Wet
|
||||||
* - Sébastien Chopin (@Atinux)
|
* - Sébastien Chopin (@Atinux)
|
||||||
@@ -13,7 +13,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|||||||
|
|
||||||
var deepmerge = _interopDefault(require('deepmerge'));
|
var deepmerge = _interopDefault(require('deepmerge'));
|
||||||
|
|
||||||
var version = "2.1.1";
|
var version = "2.2.0";
|
||||||
|
|
||||||
// store an id to keep track of DOM updates
|
// store an id to keep track of DOM updates
|
||||||
var batchId = null;
|
var batchId = null;
|
||||||
@@ -63,55 +63,6 @@ function _typeof(obj) {
|
|||||||
return _typeof(obj);
|
return _typeof(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _defineProperty(obj, key, value) {
|
|
||||||
if (key in obj) {
|
|
||||||
Object.defineProperty(obj, key, {
|
|
||||||
value: value,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
obj[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ownKeys(object, enumerableOnly) {
|
|
||||||
var keys = Object.keys(object);
|
|
||||||
|
|
||||||
if (Object.getOwnPropertySymbols) {
|
|
||||||
var symbols = Object.getOwnPropertySymbols(object);
|
|
||||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
||||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
||||||
});
|
|
||||||
keys.push.apply(keys, symbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _objectSpread2(target) {
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
|
||||||
var source = arguments[i] != null ? arguments[i] : {};
|
|
||||||
|
|
||||||
if (i % 2) {
|
|
||||||
ownKeys(source, true).forEach(function (key) {
|
|
||||||
_defineProperty(target, key, source[key]);
|
|
||||||
});
|
|
||||||
} else if (Object.getOwnPropertyDescriptors) {
|
|
||||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
||||||
} else {
|
|
||||||
ownKeys(source).forEach(function (key) {
|
|
||||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _slicedToArray(arr, i) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
@@ -256,13 +207,13 @@ var hasGlobalWindow = hasGlobalWindowFn();
|
|||||||
var _global = hasGlobalWindow ? window : global;
|
var _global = hasGlobalWindow ? window : global;
|
||||||
|
|
||||||
var console = _global.console = _global.console || {};
|
var console = _global.console = _global.console || {};
|
||||||
function warn() {
|
function warn(str) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!console || !console.warn) {
|
if (!console || !console.warn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn.apply(console, arguments);
|
console.warn(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
var appId = 1;
|
var appId = 1;
|
||||||
@@ -531,29 +482,6 @@ function resume() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTemplate(_ref, headObject, template, chunk) {
|
|
||||||
var component = _ref.component,
|
|
||||||
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
|
||||||
contentKeyName = _ref.contentKeyName;
|
|
||||||
|
|
||||||
if (isUndefined(template)) {
|
|
||||||
template = headObject[metaTemplateKeyName];
|
|
||||||
delete headObject[metaTemplateKeyName];
|
|
||||||
} // return early if no template defined
|
|
||||||
|
|
||||||
|
|
||||||
if (!template) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isUndefined(chunk)) {
|
|
||||||
chunk = headObject[contentKeyName];
|
|
||||||
}
|
|
||||||
|
|
||||||
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To reduce build size, this file provides simple polyfills without
|
* To reduce build size, this file provides simple polyfills without
|
||||||
* overly excessive type checking and without modifying
|
* overly excessive type checking and without modifying
|
||||||
@@ -563,14 +491,36 @@ 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) {
|
||||||
|
if ( !Array.prototype.findIndex) {
|
||||||
|
// idx needs to be a Number, for..in returns string
|
||||||
|
for (var idx = 0; idx < array.length; idx++) {
|
||||||
|
if (predicate.call(arguments[2], array[idx], idx, array)) {
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return array.findIndex(predicate, arguments[2]);
|
return array.findIndex(predicate, arguments[2]);
|
||||||
}
|
}
|
||||||
function toArray(arg) {
|
function toArray(arg) {
|
||||||
|
if ( !Array.from) {
|
||||||
|
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) {
|
||||||
|
for (var idx in array) {
|
||||||
|
if (array[idx] === value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return array.includes(value);
|
return array.includes(value);
|
||||||
}
|
}
|
||||||
@@ -578,13 +528,12 @@ function includes(array, value) {
|
|||||||
var serverSequences = [[/&/g, '&'], [/</g, '<'], [/>/g, '>'], [/"/g, '"'], [/'/g, ''']];
|
var serverSequences = [[/&/g, '&'], [/</g, '<'], [/>/g, '>'], [/"/g, '"'], [/'/g, ''']];
|
||||||
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
||||||
|
|
||||||
function escape(info, options, escapeOptions) {
|
function escape(info, options, escapeOptions, escapeKeys) {
|
||||||
var tagIDKeyName = options.tagIDKeyName;
|
var tagIDKeyName = options.tagIDKeyName;
|
||||||
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
||||||
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
||||||
return v;
|
return v;
|
||||||
} : _escapeOptions$doEsca,
|
} : _escapeOptions$doEsca;
|
||||||
escapeKeys = escapeOptions.escapeKeys;
|
|
||||||
var escaped = {};
|
var escaped = {};
|
||||||
|
|
||||||
for (var key in info) {
|
for (var key in info) {
|
||||||
@@ -620,17 +569,13 @@ function escape(info, options, escapeOptions) {
|
|||||||
} else if (isArray(value)) {
|
} else if (isArray(value)) {
|
||||||
escaped[key] = value.map(function (v) {
|
escaped[key] = value.map(function (v) {
|
||||||
if (isPureObject(v)) {
|
if (isPureObject(v)) {
|
||||||
return escape(v, options, _objectSpread2({}, escapeOptions, {
|
return escape(v, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return doEscape(v);
|
return doEscape(v);
|
||||||
});
|
});
|
||||||
} else if (isPureObject(value)) {
|
} else if (isPureObject(value)) {
|
||||||
escaped[key] = escape(value, options, _objectSpread2({}, escapeOptions, {
|
escaped[key] = escape(value, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
} else {
|
} else {
|
||||||
escaped[key] = value;
|
escaped[key] = value;
|
||||||
}
|
}
|
||||||
@@ -647,6 +592,56 @@ function escape(info, options, escapeOptions) {
|
|||||||
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
function escapeMetaInfo(options, info) {
|
||||||
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
|
var escapeOptions = {
|
||||||
|
doEscape: function doEscape(value) {
|
||||||
|
return escapeSequences.reduce(function (val, _ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
v = _ref2[0],
|
||||||
|
r = _ref2[1];
|
||||||
|
|
||||||
|
return val.replace(v, r);
|
||||||
|
}, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
disableOptionKeys.forEach(function (disableKey, index) {
|
||||||
|
if (index === 0) {
|
||||||
|
ensureIsArray(info, disableKey);
|
||||||
|
} else if (index === 1) {
|
||||||
|
for (var key in info[disableKey]) {
|
||||||
|
ensureIsArray(info[disableKey], key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
escapeOptions[disableKey] = info[disableKey];
|
||||||
|
}); // begin sanitization
|
||||||
|
|
||||||
|
return escape(info, options, escapeOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTemplate(_ref, headObject, template, chunk) {
|
||||||
|
var component = _ref.component,
|
||||||
|
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
||||||
|
contentKeyName = _ref.contentKeyName;
|
||||||
|
|
||||||
|
if (isUndefined(template)) {
|
||||||
|
template = headObject[metaTemplateKeyName];
|
||||||
|
delete headObject[metaTemplateKeyName];
|
||||||
|
} // return early if no template defined
|
||||||
|
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUndefined(chunk)) {
|
||||||
|
chunk = headObject[contentKeyName];
|
||||||
|
}
|
||||||
|
|
||||||
|
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function _arrayMerge(_ref, target, source) {
|
function _arrayMerge(_ref, target, source) {
|
||||||
var component = _ref.component,
|
var component = _ref.component,
|
||||||
@@ -751,6 +746,11 @@ function merge(target, source) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getComponentMetaInfo() {
|
||||||
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
|
var component = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
return getComponentOption(options, component, defaultInfo);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the `opts.option` $option value of the given `opts.component`.
|
* Returns the `opts.option` $option value of the given `opts.component`.
|
||||||
* If methods are encountered, they will be bound to the component context.
|
* If methods are encountered, they will be bound to the component context.
|
||||||
@@ -839,12 +839,12 @@ function getComponentOption() {
|
|||||||
|
|
||||||
function getMetaInfo() {
|
function getMetaInfo() {
|
||||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
var component = arguments.length > 1 ? arguments[1] : undefined;
|
var info = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
// collect & aggregate all metaInfo $options
|
var component = arguments.length > 3 ? arguments[3] : undefined;
|
||||||
var info = getComponentOption(options, component, defaultInfo); // Remove all "template" tags from meta
|
|
||||||
// backup the title chunk in case user wants access to it
|
|
||||||
|
|
||||||
|
// Remove all "template" tags from meta
|
||||||
|
// backup the title chunk in case user wants access to it
|
||||||
if (info.title) {
|
if (info.title) {
|
||||||
info.titleChunk = info.title;
|
info.titleChunk = info.title;
|
||||||
} // replace title with populated template
|
} // replace title with populated template
|
||||||
@@ -863,31 +863,7 @@ function getMetaInfo() {
|
|||||||
info.base = Object.keys(info.base).length ? [info.base] : [];
|
info.base = Object.keys(info.base).length ? [info.base] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var escapeOptions = {
|
return escapeMetaInfo(options, info, escapeSequences);
|
||||||
doEscape: function doEscape(value) {
|
|
||||||
return escapeSequences.reduce(function (val, _ref) {
|
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
|
||||||
v = _ref2[0],
|
|
||||||
r = _ref2[1];
|
|
||||||
|
|
||||||
return val.replace(v, r);
|
|
||||||
}, value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
disableOptionKeys.forEach(function (disableKey, index) {
|
|
||||||
if (index === 0) {
|
|
||||||
ensureIsArray(info, disableKey);
|
|
||||||
} else if (index === 1) {
|
|
||||||
for (var key in info[disableKey]) {
|
|
||||||
ensureIsArray(info[disableKey], key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
escapeOptions[disableKey] = info[disableKey];
|
|
||||||
}); // begin sanitization
|
|
||||||
|
|
||||||
info = escape(info, options, escapeOptions);
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTag(tags, tag) {
|
function getTag(tags, tag) {
|
||||||
@@ -936,35 +912,14 @@ function addCallback(query, callback) {
|
|||||||
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
||||||
var tagIDKeyName = _ref.tagIDKeyName;
|
var tagIDKeyName = _ref.tagIDKeyName;
|
||||||
var hasAsyncCallback = false;
|
var hasAsyncCallback = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tags.forEach(function (tag) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (!tag[tagIDKeyName] || !tag.callback) {
|
if (!tag[tagIDKeyName] || !tag.callback) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAsyncCallback = true;
|
hasAsyncCallback = true;
|
||||||
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!autoAddListeners || !hasAsyncCallback) {
|
if (!autoAddListeners || !hasAsyncCallback) {
|
||||||
return hasAsyncCallback;
|
return hasAsyncCallback;
|
||||||
@@ -986,10 +941,10 @@ function addListeners() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
function applyCallbacks(matchElement) {
|
function applyCallbacks(matchElement) {
|
||||||
var _loop = function _loop() {
|
callbacks.forEach(function (_ref2) {
|
||||||
var _callbacks$_i = _slicedToArray(_callbacks[_i], 2),
|
var _ref3 = _slicedToArray(_ref2, 2),
|
||||||
query = _callbacks$_i[0],
|
query = _ref3[0],
|
||||||
callback = _callbacks$_i[1];
|
callback = _ref3[1];
|
||||||
|
|
||||||
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
||||||
var elements = [];
|
var elements = [];
|
||||||
@@ -1002,20 +957,13 @@ function applyCallbacks(matchElement) {
|
|||||||
elements = [matchElement];
|
elements = [matchElement];
|
||||||
}
|
}
|
||||||
|
|
||||||
var _iteratorNormalCompletion2 = true;
|
elements.forEach(function (element) {
|
||||||
var _didIteratorError2 = false;
|
|
||||||
var _iteratorError2 = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop2 = function _loop2() {
|
|
||||||
var element = _step2.value;
|
|
||||||
|
|
||||||
/* __vm_cb: whether the load callback has been called
|
/* __vm_cb: whether the load callback has been called
|
||||||
* __vm_l: set by onload attribute, whether the element was loaded
|
* __vm_l: set by onload attribute, whether the element was loaded
|
||||||
* __vm_ev: whether the event listener was added or not
|
* __vm_ev: whether the event listener was added or not
|
||||||
*/
|
*/
|
||||||
if (element.__vm_cb) {
|
if (element.__vm_cb) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var onload = function onload() {
|
var onload = function onload() {
|
||||||
@@ -1042,39 +990,15 @@ function applyCallbacks(matchElement) {
|
|||||||
|
|
||||||
if (element.__vm_l) {
|
if (element.__vm_l) {
|
||||||
onload();
|
onload();
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!element.__vm_ev) {
|
if (!element.__vm_ev) {
|
||||||
element.__vm_ev = true;
|
element.__vm_ev = true;
|
||||||
element.addEventListener('load', onload);
|
element.addEventListener('load', onload);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
});
|
||||||
for (var _iterator2 = elements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
||||||
var _ret = _loop2();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError2 = true;
|
|
||||||
_iteratorError2 = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
||||||
_iterator2.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError2) {
|
|
||||||
throw _iteratorError2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
||||||
_loop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1153,7 +1077,8 @@ function updateTag(appId) {
|
|||||||
var body = arguments.length > 5 ? arguments[5] : undefined;
|
var body = arguments.length > 5 ? arguments[5] : undefined;
|
||||||
var attribute = options.attribute,
|
var attribute = options.attribute,
|
||||||
tagIDKeyName = options.tagIDKeyName;
|
tagIDKeyName = options.tagIDKeyName;
|
||||||
var dataAttributes = [tagIDKeyName].concat(_toConsumableArray(commonDataAttributes));
|
var dataAttributes = commonDataAttributes.slice();
|
||||||
|
dataAttributes.push(tagIDKeyName);
|
||||||
var newElements = [];
|
var newElements = [];
|
||||||
var queryOptions = {
|
var queryOptions = {
|
||||||
appId: appId,
|
appId: appId,
|
||||||
@@ -1184,23 +1109,15 @@ function updateTag(appId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.length) {
|
tags.forEach(function (tag) {
|
||||||
var _iteratorNormalCompletion = true;
|
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop = function _loop() {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (tag.skip) {
|
if (tag.skip) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newElement = document.createElement(type);
|
var newElement = document.createElement(type);
|
||||||
newElement.setAttribute(attribute, appId);
|
newElement.setAttribute(attribute, appId);
|
||||||
|
|
||||||
var _loop2 = function _loop2(attr) {
|
var _loop = function _loop(attr) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!tag.hasOwnProperty(attr)) {
|
if (!tag.hasOwnProperty(attr)) {
|
||||||
return "continue";
|
return "continue";
|
||||||
@@ -1248,14 +1165,14 @@ function updateTag(appId) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (var attr in tag) {
|
for (var attr in tag) {
|
||||||
var _ret2 = _loop2(attr);
|
var _ret = _loop(attr);
|
||||||
|
|
||||||
if (_ret2 === "continue") continue;
|
if (_ret === "continue") continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
||||||
|
|
||||||
var indexToDelete = void 0;
|
var indexToDelete;
|
||||||
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
||||||
indexToDelete = index;
|
indexToDelete = index;
|
||||||
return newElement.isEqualNode(existingTag);
|
return newElement.isEqualNode(existingTag);
|
||||||
@@ -1266,59 +1183,31 @@ function updateTag(appId) {
|
|||||||
} else {
|
} else {
|
||||||
newElements.push(newElement);
|
newElements.push(newElement);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var _ret = _loop();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var oldElements = [];
|
var oldElements = [];
|
||||||
|
|
||||||
for (var _i = 0, _Object$values = Object.values(currentElements); _i < _Object$values.length; _i++) {
|
for (var _type in currentElements) {
|
||||||
var current = _Object$values[_i];
|
Array.prototype.push.apply(oldElements, currentElements[_type]);
|
||||||
oldElements = [].concat(_toConsumableArray(oldElements), _toConsumableArray(current));
|
|
||||||
} // remove old elements
|
} // remove old elements
|
||||||
|
|
||||||
|
|
||||||
for (var _i2 = 0, _oldElements = oldElements; _i2 < _oldElements.length; _i2++) {
|
oldElements.forEach(function (element) {
|
||||||
var element = _oldElements[_i2];
|
|
||||||
element.parentNode.removeChild(element);
|
element.parentNode.removeChild(element);
|
||||||
} // insert new elements
|
}); // insert new elements
|
||||||
|
|
||||||
|
newElements.forEach(function (element) {
|
||||||
for (var _i3 = 0, _newElements = newElements; _i3 < _newElements.length; _i3++) {
|
if (element.hasAttribute('data-body')) {
|
||||||
var _element = _newElements[_i3];
|
body.appendChild(element);
|
||||||
|
return;
|
||||||
if (_element.hasAttribute('data-body')) {
|
|
||||||
body.appendChild(_element);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_element.hasAttribute('data-pbody')) {
|
if (element.hasAttribute('data-pbody')) {
|
||||||
body.insertBefore(_element, body.firstChild);
|
body.insertBefore(element, body.firstChild);
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
head.appendChild(_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
head.appendChild(element);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
oldTags: oldElements,
|
oldTags: oldElements,
|
||||||
newTags: newElements
|
newTags: newElements
|
||||||
@@ -1345,32 +1234,11 @@ function updateClientMetaInfo(appId) {
|
|||||||
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
||||||
|
|
||||||
var addLoadListeners = false;
|
var addLoadListeners = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tagsSupportingOnload.forEach(function (type) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tagsSupportingOnload[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var type = _step.value;
|
|
||||||
|
|
||||||
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
||||||
addLoadListeners = true;
|
addLoadListeners = true;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addLoadListeners) {
|
if (addLoadListeners) {
|
||||||
addListeners();
|
addListeners();
|
||||||
@@ -1383,37 +1251,36 @@ function updateClientMetaInfo(appId) {
|
|||||||
var addedTags = {};
|
var addedTags = {};
|
||||||
var removedTags = {};
|
var removedTags = {};
|
||||||
|
|
||||||
for (var _type in newInfo) {
|
for (var type in newInfo) {
|
||||||
// ignore these
|
// ignore these
|
||||||
if (includes(metaInfoOptionKeys, _type)) {
|
if (includes(metaInfoOptionKeys, type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_type === 'title') {
|
if (type === 'title') {
|
||||||
// update the title
|
// update the title
|
||||||
updateTitle(newInfo.title);
|
updateTitle(newInfo.title);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includes(metaInfoAttributeKeys, _type)) {
|
if (includes(metaInfoAttributeKeys, type)) {
|
||||||
var tagName = _type.substr(0, 4);
|
var tagName = type.substr(0, 4);
|
||||||
|
updateAttribute(options, newInfo[type], getTag(tags, tagName));
|
||||||
updateAttribute(options, newInfo[_type], getTag(tags, tagName));
|
|
||||||
continue;
|
continue;
|
||||||
} // tags should always be an array, ignore if it isnt
|
} // tags should always be an array, ignore if it isnt
|
||||||
|
|
||||||
|
|
||||||
if (!isArray(newInfo[_type])) {
|
if (!isArray(newInfo[type])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _updateTag = updateTag(appId, options, _type, newInfo[_type], getTag(tags, 'head'), getTag(tags, 'body')),
|
var _updateTag = updateTag(appId, options, type, newInfo[type], getTag(tags, 'head'), getTag(tags, 'body')),
|
||||||
oldTags = _updateTag.oldTags,
|
oldTags = _updateTag.oldTags,
|
||||||
newTags = _updateTag.newTags;
|
newTags = _updateTag.newTags;
|
||||||
|
|
||||||
if (newTags.length) {
|
if (newTags.length) {
|
||||||
addedTags[_type] = newTags;
|
addedTags[type] = newTags;
|
||||||
removedTags[_type] = oldTags;
|
removedTags[type] = oldTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1437,7 +1304,9 @@ function _refresh() {
|
|||||||
* @return {Object} - new meta info
|
* @return {Object} - new meta info
|
||||||
*/
|
*/
|
||||||
return function refresh() {
|
return function refresh() {
|
||||||
var metaInfo = getMetaInfo(options, this.$root, clientSequences);
|
// collect & aggregate all metaInfo $options
|
||||||
|
var rawInfo = getComponentMetaInfo(options, this.$root);
|
||||||
|
var metaInfo = getMetaInfo(options, rawInfo, clientSequences, this.$root);
|
||||||
var appId = this.$root._vueMeta.appId;
|
var appId = this.$root._vueMeta.appId;
|
||||||
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
||||||
|
|
||||||
@@ -1534,7 +1403,7 @@ function tagGenerator() {
|
|||||||
|
|
||||||
var type = arguments.length > 1 ? arguments[1] : undefined;
|
var type = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
var tags = arguments.length > 2 ? arguments[2] : undefined;
|
var tags = arguments.length > 2 ? arguments[2] : undefined;
|
||||||
var dataAttributes = [tagIDKeyName, 'callback'].concat(_toConsumableArray(commonDataAttributes));
|
var dataAttributes = [tagIDKeyName].concat(_toConsumableArray(commonDataAttributes));
|
||||||
return {
|
return {
|
||||||
text: function text() {
|
text: function text() {
|
||||||
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
||||||
@@ -1543,7 +1412,11 @@ function tagGenerator() {
|
|||||||
_ref2$pbody = _ref2.pbody,
|
_ref2$pbody = _ref2.pbody,
|
||||||
pbody = _ref2$pbody === void 0 ? false : _ref2$pbody;
|
pbody = _ref2$pbody === void 0 ? false : _ref2$pbody;
|
||||||
|
|
||||||
// build a string containing all tags of this type
|
if (!tags || !tags.length) {
|
||||||
|
return '';
|
||||||
|
} // build a string containing all tags of this type
|
||||||
|
|
||||||
|
|
||||||
return tags.reduce(function (tagsStr, tag) {
|
return tags.reduce(function (tagsStr, tag) {
|
||||||
if (tag.skip) {
|
if (tag.skip) {
|
||||||
return tagsStr;
|
return tagsStr;
|
||||||
@@ -1565,6 +1438,11 @@ function tagGenerator() {
|
|||||||
// these attributes are treated as children on the tag
|
// these attributes are treated as children on the tag
|
||||||
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
|
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attr === 'callback') {
|
||||||
|
attrs += " onload=\"this.__vm_l=1\"";
|
||||||
|
continue;
|
||||||
} // these form the attribute list for this tag
|
} // these form the attribute list for this tag
|
||||||
|
|
||||||
|
|
||||||
@@ -1574,11 +1452,6 @@ function tagGenerator() {
|
|||||||
prefix = 'data-';
|
prefix = 'data-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr === 'callback') {
|
|
||||||
attrs += " onload=\"this.__vm_l=1\"";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var isBooleanAttr = !prefix && booleanHtmlAttributes.includes(attr);
|
var isBooleanAttr = !prefix && booleanHtmlAttributes.includes(attr);
|
||||||
|
|
||||||
if (isBooleanAttr && !tag[attr]) {
|
if (isBooleanAttr && !tag[attr]) {
|
||||||
@@ -1616,16 +1489,26 @@ function tagGenerator() {
|
|||||||
* @return {Object} - the new injector
|
* @return {Object} - the new injector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function generateServerInjector(options, type, data) {
|
function generateServerInjector(options, newInfo) {
|
||||||
|
for (var type in defaultInfo) {
|
||||||
|
if (metaInfoOptionKeys.includes(type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'title') {
|
if (type === 'title') {
|
||||||
return titleGenerator(options, type, data);
|
newInfo[type] = titleGenerator(options, type, newInfo[type]);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaInfoAttributeKeys.includes(type)) {
|
if (metaInfoAttributeKeys.includes(type)) {
|
||||||
return attributeGenerator(options, type, data);
|
newInfo[type] = attributeGenerator(options, type, newInfo[type]);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tagGenerator(options, type, data);
|
newInfo[type] = tagGenerator(options, type, newInfo[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _inject() {
|
function _inject() {
|
||||||
@@ -1639,15 +1522,11 @@ function _inject() {
|
|||||||
* @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
|
// collect & aggregate all metaInfo $options
|
||||||
var metaInfo = getMetaInfo(options, this.$root, serverSequences); // generate server injectors
|
var rawInfo = getComponentMetaInfo(options, this.$root);
|
||||||
|
var metaInfo = getMetaInfo(options, rawInfo, serverSequences, this.$root); // generate server injectors
|
||||||
for (var key in metaInfo) {
|
|
||||||
if (!metaInfoOptionKeys.includes(key) && metaInfo.hasOwnProperty(key)) {
|
|
||||||
metaInfo[key] = generateServerInjector(options, key, metaInfo[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
generateServerInjector(options, metaInfo);
|
||||||
return metaInfo;
|
return metaInfo;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1678,6 +1557,12 @@ function _$meta() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generate(rawInfo) {
|
||||||
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||||
|
var metaInfo = getMetaInfo(setOptions(options), rawInfo, serverSequences);
|
||||||
|
return generateServerInjector(options, metaInfo);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin install function.
|
* Plugin install function.
|
||||||
* @param {Function} Vue - the Vue constructor.
|
* @param {Function} Vue - the Vue constructor.
|
||||||
@@ -1699,7 +1584,8 @@ function install(Vue) {
|
|||||||
var index = {
|
var index = {
|
||||||
version: version,
|
version: version,
|
||||||
install: install,
|
install: install,
|
||||||
hasMetaInfo: hasMetaInfo
|
hasMetaInfo: hasMetaInfo,
|
||||||
|
generate: generate
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = index;
|
module.exports = index;
|
||||||
|
|||||||
Vendored
+139
-290
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v2.1.1
|
* vue-meta v2.2.0
|
||||||
* (c) 2019
|
* (c) 2019
|
||||||
* - Declan de Wet
|
* - Declan de Wet
|
||||||
* - Sébastien Chopin (@Atinux)
|
* - Sébastien Chopin (@Atinux)
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import deepmerge from 'deepmerge';
|
import deepmerge from 'deepmerge';
|
||||||
|
|
||||||
var version = "2.1.1";
|
var version = "2.2.0";
|
||||||
|
|
||||||
// store an id to keep track of DOM updates
|
// store an id to keep track of DOM updates
|
||||||
var batchId = null;
|
var batchId = null;
|
||||||
@@ -59,79 +59,14 @@ function _typeof(obj) {
|
|||||||
return _typeof(obj);
|
return _typeof(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _defineProperty(obj, key, value) {
|
|
||||||
if (key in obj) {
|
|
||||||
Object.defineProperty(obj, key, {
|
|
||||||
value: value,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
obj[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ownKeys(object, enumerableOnly) {
|
|
||||||
var keys = Object.keys(object);
|
|
||||||
|
|
||||||
if (Object.getOwnPropertySymbols) {
|
|
||||||
var symbols = Object.getOwnPropertySymbols(object);
|
|
||||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
||||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
||||||
});
|
|
||||||
keys.push.apply(keys, symbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _objectSpread2(target) {
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
|
||||||
var source = arguments[i] != null ? arguments[i] : {};
|
|
||||||
|
|
||||||
if (i % 2) {
|
|
||||||
ownKeys(source, true).forEach(function (key) {
|
|
||||||
_defineProperty(target, key, source[key]);
|
|
||||||
});
|
|
||||||
} else if (Object.getOwnPropertyDescriptors) {
|
|
||||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
||||||
} else {
|
|
||||||
ownKeys(source).forEach(function (key) {
|
|
||||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _slicedToArray(arr, i) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _toConsumableArray(arr) {
|
|
||||||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _arrayWithoutHoles(arr) {
|
|
||||||
if (Array.isArray(arr)) {
|
|
||||||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
||||||
|
|
||||||
return arr2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _arrayWithHoles(arr) {
|
function _arrayWithHoles(arr) {
|
||||||
if (Array.isArray(arr)) return arr;
|
if (Array.isArray(arr)) return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _iterableToArray(iter) {
|
|
||||||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _iterableToArrayLimit(arr, i) {
|
function _iterableToArrayLimit(arr, i) {
|
||||||
var _arr = [];
|
var _arr = [];
|
||||||
var _n = true;
|
var _n = true;
|
||||||
@@ -158,10 +93,6 @@ function _iterableToArrayLimit(arr, i) {
|
|||||||
return _arr;
|
return _arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _nonIterableSpread() {
|
|
||||||
throw new TypeError("Invalid attempt to spread non-iterable instance");
|
|
||||||
}
|
|
||||||
|
|
||||||
function _nonIterableRest() {
|
function _nonIterableRest() {
|
||||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||||
}
|
}
|
||||||
@@ -252,13 +183,13 @@ var hasGlobalWindow = hasGlobalWindowFn();
|
|||||||
var _global = hasGlobalWindow ? window : global;
|
var _global = hasGlobalWindow ? window : global;
|
||||||
|
|
||||||
var console = _global.console = _global.console || {};
|
var console = _global.console = _global.console || {};
|
||||||
function warn() {
|
function warn(str) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!console || !console.warn) {
|
if (!console || !console.warn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn.apply(console, arguments);
|
console.warn(str);
|
||||||
}
|
}
|
||||||
var showWarningNotSupported = function showWarningNotSupported() {
|
var showWarningNotSupported = function showWarningNotSupported() {
|
||||||
return warn('This vue app/component has no vue-meta configuration');
|
return warn('This vue app/component has no vue-meta configuration');
|
||||||
@@ -523,29 +454,6 @@ function resume() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTemplate(_ref, headObject, template, chunk) {
|
|
||||||
var component = _ref.component,
|
|
||||||
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
|
||||||
contentKeyName = _ref.contentKeyName;
|
|
||||||
|
|
||||||
if (isUndefined(template)) {
|
|
||||||
template = headObject[metaTemplateKeyName];
|
|
||||||
delete headObject[metaTemplateKeyName];
|
|
||||||
} // return early if no template defined
|
|
||||||
|
|
||||||
|
|
||||||
if (!template) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isUndefined(chunk)) {
|
|
||||||
chunk = headObject[contentKeyName];
|
|
||||||
}
|
|
||||||
|
|
||||||
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To reduce build size, this file provides simple polyfills without
|
* To reduce build size, this file provides simple polyfills without
|
||||||
* overly excessive type checking and without modifying
|
* overly excessive type checking and without modifying
|
||||||
@@ -555,27 +463,48 @@ 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) {
|
||||||
|
if ( !Array.prototype.findIndex) {
|
||||||
|
// idx needs to be a Number, for..in returns string
|
||||||
|
for (var idx = 0; idx < array.length; idx++) {
|
||||||
|
if (predicate.call(arguments[2], array[idx], idx, array)) {
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return array.findIndex(predicate, arguments[2]);
|
return array.findIndex(predicate, arguments[2]);
|
||||||
}
|
}
|
||||||
function toArray(arg) {
|
function toArray(arg) {
|
||||||
|
if ( !Array.from) {
|
||||||
|
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) {
|
||||||
|
for (var idx in array) {
|
||||||
|
if (array[idx] === value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return array.includes(value);
|
return array.includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
||||||
|
|
||||||
function escape(info, options, escapeOptions) {
|
function escape(info, options, escapeOptions, escapeKeys) {
|
||||||
var tagIDKeyName = options.tagIDKeyName;
|
var tagIDKeyName = options.tagIDKeyName;
|
||||||
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
||||||
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
||||||
return v;
|
return v;
|
||||||
} : _escapeOptions$doEsca,
|
} : _escapeOptions$doEsca;
|
||||||
escapeKeys = escapeOptions.escapeKeys;
|
|
||||||
var escaped = {};
|
var escaped = {};
|
||||||
|
|
||||||
for (var key in info) {
|
for (var key in info) {
|
||||||
@@ -611,17 +540,13 @@ function escape(info, options, escapeOptions) {
|
|||||||
} else if (isArray(value)) {
|
} else if (isArray(value)) {
|
||||||
escaped[key] = value.map(function (v) {
|
escaped[key] = value.map(function (v) {
|
||||||
if (isPureObject(v)) {
|
if (isPureObject(v)) {
|
||||||
return escape(v, options, _objectSpread2({}, escapeOptions, {
|
return escape(v, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return doEscape(v);
|
return doEscape(v);
|
||||||
});
|
});
|
||||||
} else if (isPureObject(value)) {
|
} else if (isPureObject(value)) {
|
||||||
escaped[key] = escape(value, options, _objectSpread2({}, escapeOptions, {
|
escaped[key] = escape(value, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
} else {
|
} else {
|
||||||
escaped[key] = value;
|
escaped[key] = value;
|
||||||
}
|
}
|
||||||
@@ -638,6 +563,56 @@ function escape(info, options, escapeOptions) {
|
|||||||
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
function escapeMetaInfo(options, info) {
|
||||||
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
|
var escapeOptions = {
|
||||||
|
doEscape: function doEscape(value) {
|
||||||
|
return escapeSequences.reduce(function (val, _ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
v = _ref2[0],
|
||||||
|
r = _ref2[1];
|
||||||
|
|
||||||
|
return val.replace(v, r);
|
||||||
|
}, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
disableOptionKeys.forEach(function (disableKey, index) {
|
||||||
|
if (index === 0) {
|
||||||
|
ensureIsArray(info, disableKey);
|
||||||
|
} else if (index === 1) {
|
||||||
|
for (var key in info[disableKey]) {
|
||||||
|
ensureIsArray(info[disableKey], key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
escapeOptions[disableKey] = info[disableKey];
|
||||||
|
}); // begin sanitization
|
||||||
|
|
||||||
|
return escape(info, options, escapeOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTemplate(_ref, headObject, template, chunk) {
|
||||||
|
var component = _ref.component,
|
||||||
|
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
||||||
|
contentKeyName = _ref.contentKeyName;
|
||||||
|
|
||||||
|
if (isUndefined(template)) {
|
||||||
|
template = headObject[metaTemplateKeyName];
|
||||||
|
delete headObject[metaTemplateKeyName];
|
||||||
|
} // return early if no template defined
|
||||||
|
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUndefined(chunk)) {
|
||||||
|
chunk = headObject[contentKeyName];
|
||||||
|
}
|
||||||
|
|
||||||
|
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function _arrayMerge(_ref, target, source) {
|
function _arrayMerge(_ref, target, source) {
|
||||||
var component = _ref.component,
|
var component = _ref.component,
|
||||||
@@ -742,6 +717,11 @@ function merge(target, source) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getComponentMetaInfo() {
|
||||||
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
|
var component = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
return getComponentOption(options, component, defaultInfo);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the `opts.option` $option value of the given `opts.component`.
|
* Returns the `opts.option` $option value of the given `opts.component`.
|
||||||
* If methods are encountered, they will be bound to the component context.
|
* If methods are encountered, they will be bound to the component context.
|
||||||
@@ -830,12 +810,12 @@ function getComponentOption() {
|
|||||||
|
|
||||||
function getMetaInfo() {
|
function getMetaInfo() {
|
||||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
var component = arguments.length > 1 ? arguments[1] : undefined;
|
var info = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
// collect & aggregate all metaInfo $options
|
var component = arguments.length > 3 ? arguments[3] : undefined;
|
||||||
var info = getComponentOption(options, component, defaultInfo); // Remove all "template" tags from meta
|
|
||||||
// backup the title chunk in case user wants access to it
|
|
||||||
|
|
||||||
|
// Remove all "template" tags from meta
|
||||||
|
// backup the title chunk in case user wants access to it
|
||||||
if (info.title) {
|
if (info.title) {
|
||||||
info.titleChunk = info.title;
|
info.titleChunk = info.title;
|
||||||
} // replace title with populated template
|
} // replace title with populated template
|
||||||
@@ -854,31 +834,7 @@ function getMetaInfo() {
|
|||||||
info.base = Object.keys(info.base).length ? [info.base] : [];
|
info.base = Object.keys(info.base).length ? [info.base] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var escapeOptions = {
|
return escapeMetaInfo(options, info, escapeSequences);
|
||||||
doEscape: function doEscape(value) {
|
|
||||||
return escapeSequences.reduce(function (val, _ref) {
|
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
|
||||||
v = _ref2[0],
|
|
||||||
r = _ref2[1];
|
|
||||||
|
|
||||||
return val.replace(v, r);
|
|
||||||
}, value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
disableOptionKeys.forEach(function (disableKey, index) {
|
|
||||||
if (index === 0) {
|
|
||||||
ensureIsArray(info, disableKey);
|
|
||||||
} else if (index === 1) {
|
|
||||||
for (var key in info[disableKey]) {
|
|
||||||
ensureIsArray(info[disableKey], key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
escapeOptions[disableKey] = info[disableKey];
|
|
||||||
}); // begin sanitization
|
|
||||||
|
|
||||||
info = escape(info, options, escapeOptions);
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTag(tags, tag) {
|
function getTag(tags, tag) {
|
||||||
@@ -927,35 +883,14 @@ function addCallback(query, callback) {
|
|||||||
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
||||||
var tagIDKeyName = _ref.tagIDKeyName;
|
var tagIDKeyName = _ref.tagIDKeyName;
|
||||||
var hasAsyncCallback = false;
|
var hasAsyncCallback = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tags.forEach(function (tag) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (!tag[tagIDKeyName] || !tag.callback) {
|
if (!tag[tagIDKeyName] || !tag.callback) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAsyncCallback = true;
|
hasAsyncCallback = true;
|
||||||
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!autoAddListeners || !hasAsyncCallback) {
|
if (!autoAddListeners || !hasAsyncCallback) {
|
||||||
return hasAsyncCallback;
|
return hasAsyncCallback;
|
||||||
@@ -977,10 +912,10 @@ function addListeners() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
function applyCallbacks(matchElement) {
|
function applyCallbacks(matchElement) {
|
||||||
var _loop = function _loop() {
|
callbacks.forEach(function (_ref2) {
|
||||||
var _callbacks$_i = _slicedToArray(_callbacks[_i], 2),
|
var _ref3 = _slicedToArray(_ref2, 2),
|
||||||
query = _callbacks$_i[0],
|
query = _ref3[0],
|
||||||
callback = _callbacks$_i[1];
|
callback = _ref3[1];
|
||||||
|
|
||||||
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
||||||
var elements = [];
|
var elements = [];
|
||||||
@@ -993,20 +928,13 @@ function applyCallbacks(matchElement) {
|
|||||||
elements = [matchElement];
|
elements = [matchElement];
|
||||||
}
|
}
|
||||||
|
|
||||||
var _iteratorNormalCompletion2 = true;
|
elements.forEach(function (element) {
|
||||||
var _didIteratorError2 = false;
|
|
||||||
var _iteratorError2 = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop2 = function _loop2() {
|
|
||||||
var element = _step2.value;
|
|
||||||
|
|
||||||
/* __vm_cb: whether the load callback has been called
|
/* __vm_cb: whether the load callback has been called
|
||||||
* __vm_l: set by onload attribute, whether the element was loaded
|
* __vm_l: set by onload attribute, whether the element was loaded
|
||||||
* __vm_ev: whether the event listener was added or not
|
* __vm_ev: whether the event listener was added or not
|
||||||
*/
|
*/
|
||||||
if (element.__vm_cb) {
|
if (element.__vm_cb) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var onload = function onload() {
|
var onload = function onload() {
|
||||||
@@ -1033,39 +961,15 @@ function applyCallbacks(matchElement) {
|
|||||||
|
|
||||||
if (element.__vm_l) {
|
if (element.__vm_l) {
|
||||||
onload();
|
onload();
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!element.__vm_ev) {
|
if (!element.__vm_ev) {
|
||||||
element.__vm_ev = true;
|
element.__vm_ev = true;
|
||||||
element.addEventListener('load', onload);
|
element.addEventListener('load', onload);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
});
|
||||||
for (var _iterator2 = elements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
||||||
var _ret = _loop2();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError2 = true;
|
|
||||||
_iteratorError2 = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
||||||
_iterator2.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError2) {
|
|
||||||
throw _iteratorError2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
||||||
_loop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1144,7 +1048,8 @@ function updateTag(appId) {
|
|||||||
var body = arguments.length > 5 ? arguments[5] : undefined;
|
var body = arguments.length > 5 ? arguments[5] : undefined;
|
||||||
var attribute = options.attribute,
|
var attribute = options.attribute,
|
||||||
tagIDKeyName = options.tagIDKeyName;
|
tagIDKeyName = options.tagIDKeyName;
|
||||||
var dataAttributes = [tagIDKeyName].concat(_toConsumableArray(commonDataAttributes));
|
var dataAttributes = commonDataAttributes.slice();
|
||||||
|
dataAttributes.push(tagIDKeyName);
|
||||||
var newElements = [];
|
var newElements = [];
|
||||||
var queryOptions = {
|
var queryOptions = {
|
||||||
appId: appId,
|
appId: appId,
|
||||||
@@ -1175,23 +1080,15 @@ function updateTag(appId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.length) {
|
tags.forEach(function (tag) {
|
||||||
var _iteratorNormalCompletion = true;
|
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop = function _loop() {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (tag.skip) {
|
if (tag.skip) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newElement = document.createElement(type);
|
var newElement = document.createElement(type);
|
||||||
newElement.setAttribute(attribute, appId);
|
newElement.setAttribute(attribute, appId);
|
||||||
|
|
||||||
var _loop2 = function _loop2(attr) {
|
var _loop = function _loop(attr) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!tag.hasOwnProperty(attr)) {
|
if (!tag.hasOwnProperty(attr)) {
|
||||||
return "continue";
|
return "continue";
|
||||||
@@ -1239,14 +1136,14 @@ function updateTag(appId) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (var attr in tag) {
|
for (var attr in tag) {
|
||||||
var _ret2 = _loop2(attr);
|
var _ret = _loop(attr);
|
||||||
|
|
||||||
if (_ret2 === "continue") continue;
|
if (_ret === "continue") continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
||||||
|
|
||||||
var indexToDelete = void 0;
|
var indexToDelete;
|
||||||
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
||||||
indexToDelete = index;
|
indexToDelete = index;
|
||||||
return newElement.isEqualNode(existingTag);
|
return newElement.isEqualNode(existingTag);
|
||||||
@@ -1257,59 +1154,31 @@ function updateTag(appId) {
|
|||||||
} else {
|
} else {
|
||||||
newElements.push(newElement);
|
newElements.push(newElement);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var _ret = _loop();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var oldElements = [];
|
var oldElements = [];
|
||||||
|
|
||||||
for (var _i = 0, _Object$values = Object.values(currentElements); _i < _Object$values.length; _i++) {
|
for (var _type in currentElements) {
|
||||||
var current = _Object$values[_i];
|
Array.prototype.push.apply(oldElements, currentElements[_type]);
|
||||||
oldElements = [].concat(_toConsumableArray(oldElements), _toConsumableArray(current));
|
|
||||||
} // remove old elements
|
} // remove old elements
|
||||||
|
|
||||||
|
|
||||||
for (var _i2 = 0, _oldElements = oldElements; _i2 < _oldElements.length; _i2++) {
|
oldElements.forEach(function (element) {
|
||||||
var element = _oldElements[_i2];
|
|
||||||
element.parentNode.removeChild(element);
|
element.parentNode.removeChild(element);
|
||||||
} // insert new elements
|
}); // insert new elements
|
||||||
|
|
||||||
|
newElements.forEach(function (element) {
|
||||||
for (var _i3 = 0, _newElements = newElements; _i3 < _newElements.length; _i3++) {
|
if (element.hasAttribute('data-body')) {
|
||||||
var _element = _newElements[_i3];
|
body.appendChild(element);
|
||||||
|
return;
|
||||||
if (_element.hasAttribute('data-body')) {
|
|
||||||
body.appendChild(_element);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_element.hasAttribute('data-pbody')) {
|
if (element.hasAttribute('data-pbody')) {
|
||||||
body.insertBefore(_element, body.firstChild);
|
body.insertBefore(element, body.firstChild);
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
head.appendChild(_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
head.appendChild(element);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
oldTags: oldElements,
|
oldTags: oldElements,
|
||||||
newTags: newElements
|
newTags: newElements
|
||||||
@@ -1336,32 +1205,11 @@ function updateClientMetaInfo(appId) {
|
|||||||
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
||||||
|
|
||||||
var addLoadListeners = false;
|
var addLoadListeners = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tagsSupportingOnload.forEach(function (type) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tagsSupportingOnload[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var type = _step.value;
|
|
||||||
|
|
||||||
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
||||||
addLoadListeners = true;
|
addLoadListeners = true;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addLoadListeners) {
|
if (addLoadListeners) {
|
||||||
addListeners();
|
addListeners();
|
||||||
@@ -1374,37 +1222,36 @@ function updateClientMetaInfo(appId) {
|
|||||||
var addedTags = {};
|
var addedTags = {};
|
||||||
var removedTags = {};
|
var removedTags = {};
|
||||||
|
|
||||||
for (var _type in newInfo) {
|
for (var type in newInfo) {
|
||||||
// ignore these
|
// ignore these
|
||||||
if (includes(metaInfoOptionKeys, _type)) {
|
if (includes(metaInfoOptionKeys, type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_type === 'title') {
|
if (type === 'title') {
|
||||||
// update the title
|
// update the title
|
||||||
updateTitle(newInfo.title);
|
updateTitle(newInfo.title);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includes(metaInfoAttributeKeys, _type)) {
|
if (includes(metaInfoAttributeKeys, type)) {
|
||||||
var tagName = _type.substr(0, 4);
|
var tagName = type.substr(0, 4);
|
||||||
|
updateAttribute(options, newInfo[type], getTag(tags, tagName));
|
||||||
updateAttribute(options, newInfo[_type], getTag(tags, tagName));
|
|
||||||
continue;
|
continue;
|
||||||
} // tags should always be an array, ignore if it isnt
|
} // tags should always be an array, ignore if it isnt
|
||||||
|
|
||||||
|
|
||||||
if (!isArray(newInfo[_type])) {
|
if (!isArray(newInfo[type])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _updateTag = updateTag(appId, options, _type, newInfo[_type], getTag(tags, 'head'), getTag(tags, 'body')),
|
var _updateTag = updateTag(appId, options, type, newInfo[type], getTag(tags, 'head'), getTag(tags, 'body')),
|
||||||
oldTags = _updateTag.oldTags,
|
oldTags = _updateTag.oldTags,
|
||||||
newTags = _updateTag.newTags;
|
newTags = _updateTag.newTags;
|
||||||
|
|
||||||
if (newTags.length) {
|
if (newTags.length) {
|
||||||
addedTags[_type] = newTags;
|
addedTags[type] = newTags;
|
||||||
removedTags[_type] = oldTags;
|
removedTags[type] = oldTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1428,7 +1275,9 @@ function _refresh() {
|
|||||||
* @return {Object} - new meta info
|
* @return {Object} - new meta info
|
||||||
*/
|
*/
|
||||||
return function refresh() {
|
return function refresh() {
|
||||||
var metaInfo = getMetaInfo(options, this.$root, clientSequences);
|
// collect & aggregate all metaInfo $options
|
||||||
|
var rawInfo = getComponentMetaInfo(options, this.$root);
|
||||||
|
var metaInfo = getMetaInfo(options, rawInfo, clientSequences, this.$root);
|
||||||
var appId = this.$root._vueMeta.appId;
|
var appId = this.$root._vueMeta.appId;
|
||||||
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+176
-290
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v2.1.1
|
* vue-meta v2.2.0
|
||||||
* (c) 2019
|
* (c) 2019
|
||||||
* - Declan de Wet
|
* - Declan de Wet
|
||||||
* - Sébastien Chopin (@Atinux)
|
* - Sébastien Chopin (@Atinux)
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import deepmerge from 'deepmerge';
|
import deepmerge from 'deepmerge';
|
||||||
|
|
||||||
var version = "2.1.1";
|
var version = "2.2.0";
|
||||||
|
|
||||||
// store an id to keep track of DOM updates
|
// store an id to keep track of DOM updates
|
||||||
var batchId = null;
|
var batchId = null;
|
||||||
@@ -59,55 +59,6 @@ function _typeof(obj) {
|
|||||||
return _typeof(obj);
|
return _typeof(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _defineProperty(obj, key, value) {
|
|
||||||
if (key in obj) {
|
|
||||||
Object.defineProperty(obj, key, {
|
|
||||||
value: value,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
obj[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ownKeys(object, enumerableOnly) {
|
|
||||||
var keys = Object.keys(object);
|
|
||||||
|
|
||||||
if (Object.getOwnPropertySymbols) {
|
|
||||||
var symbols = Object.getOwnPropertySymbols(object);
|
|
||||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
||||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
||||||
});
|
|
||||||
keys.push.apply(keys, symbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _objectSpread2(target) {
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
|
||||||
var source = arguments[i] != null ? arguments[i] : {};
|
|
||||||
|
|
||||||
if (i % 2) {
|
|
||||||
ownKeys(source, true).forEach(function (key) {
|
|
||||||
_defineProperty(target, key, source[key]);
|
|
||||||
});
|
|
||||||
} else if (Object.getOwnPropertyDescriptors) {
|
|
||||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
||||||
} else {
|
|
||||||
ownKeys(source).forEach(function (key) {
|
|
||||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _slicedToArray(arr, i) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
@@ -252,13 +203,13 @@ var hasGlobalWindow = hasGlobalWindowFn();
|
|||||||
var _global = hasGlobalWindow ? window : global;
|
var _global = hasGlobalWindow ? window : global;
|
||||||
|
|
||||||
var console = _global.console = _global.console || {};
|
var console = _global.console = _global.console || {};
|
||||||
function warn() {
|
function warn(str) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!console || !console.warn) {
|
if (!console || !console.warn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn.apply(console, arguments);
|
console.warn(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
var appId = 1;
|
var appId = 1;
|
||||||
@@ -527,29 +478,6 @@ function resume() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTemplate(_ref, headObject, template, chunk) {
|
|
||||||
var component = _ref.component,
|
|
||||||
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
|
||||||
contentKeyName = _ref.contentKeyName;
|
|
||||||
|
|
||||||
if (isUndefined(template)) {
|
|
||||||
template = headObject[metaTemplateKeyName];
|
|
||||||
delete headObject[metaTemplateKeyName];
|
|
||||||
} // return early if no template defined
|
|
||||||
|
|
||||||
|
|
||||||
if (!template) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isUndefined(chunk)) {
|
|
||||||
chunk = headObject[contentKeyName];
|
|
||||||
}
|
|
||||||
|
|
||||||
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To reduce build size, this file provides simple polyfills without
|
* To reduce build size, this file provides simple polyfills without
|
||||||
* overly excessive type checking and without modifying
|
* overly excessive type checking and without modifying
|
||||||
@@ -559,14 +487,36 @@ 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) {
|
||||||
|
if ( !Array.prototype.findIndex) {
|
||||||
|
// idx needs to be a Number, for..in returns string
|
||||||
|
for (var idx = 0; idx < array.length; idx++) {
|
||||||
|
if (predicate.call(arguments[2], array[idx], idx, array)) {
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return array.findIndex(predicate, arguments[2]);
|
return array.findIndex(predicate, arguments[2]);
|
||||||
}
|
}
|
||||||
function toArray(arg) {
|
function toArray(arg) {
|
||||||
|
if ( !Array.from) {
|
||||||
|
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) {
|
||||||
|
for (var idx in array) {
|
||||||
|
if (array[idx] === value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return array.includes(value);
|
return array.includes(value);
|
||||||
}
|
}
|
||||||
@@ -574,13 +524,12 @@ function includes(array, value) {
|
|||||||
var serverSequences = [[/&/g, '&'], [/</g, '<'], [/>/g, '>'], [/"/g, '"'], [/'/g, ''']];
|
var serverSequences = [[/&/g, '&'], [/</g, '<'], [/>/g, '>'], [/"/g, '"'], [/'/g, ''']];
|
||||||
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
||||||
|
|
||||||
function escape(info, options, escapeOptions) {
|
function escape(info, options, escapeOptions, escapeKeys) {
|
||||||
var tagIDKeyName = options.tagIDKeyName;
|
var tagIDKeyName = options.tagIDKeyName;
|
||||||
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
||||||
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
||||||
return v;
|
return v;
|
||||||
} : _escapeOptions$doEsca,
|
} : _escapeOptions$doEsca;
|
||||||
escapeKeys = escapeOptions.escapeKeys;
|
|
||||||
var escaped = {};
|
var escaped = {};
|
||||||
|
|
||||||
for (var key in info) {
|
for (var key in info) {
|
||||||
@@ -616,17 +565,13 @@ function escape(info, options, escapeOptions) {
|
|||||||
} else if (isArray(value)) {
|
} else if (isArray(value)) {
|
||||||
escaped[key] = value.map(function (v) {
|
escaped[key] = value.map(function (v) {
|
||||||
if (isPureObject(v)) {
|
if (isPureObject(v)) {
|
||||||
return escape(v, options, _objectSpread2({}, escapeOptions, {
|
return escape(v, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return doEscape(v);
|
return doEscape(v);
|
||||||
});
|
});
|
||||||
} else if (isPureObject(value)) {
|
} else if (isPureObject(value)) {
|
||||||
escaped[key] = escape(value, options, _objectSpread2({}, escapeOptions, {
|
escaped[key] = escape(value, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
} else {
|
} else {
|
||||||
escaped[key] = value;
|
escaped[key] = value;
|
||||||
}
|
}
|
||||||
@@ -643,6 +588,56 @@ function escape(info, options, escapeOptions) {
|
|||||||
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
function escapeMetaInfo(options, info) {
|
||||||
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
|
var escapeOptions = {
|
||||||
|
doEscape: function doEscape(value) {
|
||||||
|
return escapeSequences.reduce(function (val, _ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
v = _ref2[0],
|
||||||
|
r = _ref2[1];
|
||||||
|
|
||||||
|
return val.replace(v, r);
|
||||||
|
}, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
disableOptionKeys.forEach(function (disableKey, index) {
|
||||||
|
if (index === 0) {
|
||||||
|
ensureIsArray(info, disableKey);
|
||||||
|
} else if (index === 1) {
|
||||||
|
for (var key in info[disableKey]) {
|
||||||
|
ensureIsArray(info[disableKey], key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
escapeOptions[disableKey] = info[disableKey];
|
||||||
|
}); // begin sanitization
|
||||||
|
|
||||||
|
return escape(info, options, escapeOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyTemplate(_ref, headObject, template, chunk) {
|
||||||
|
var component = _ref.component,
|
||||||
|
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
||||||
|
contentKeyName = _ref.contentKeyName;
|
||||||
|
|
||||||
|
if (isUndefined(template)) {
|
||||||
|
template = headObject[metaTemplateKeyName];
|
||||||
|
delete headObject[metaTemplateKeyName];
|
||||||
|
} // return early if no template defined
|
||||||
|
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUndefined(chunk)) {
|
||||||
|
chunk = headObject[contentKeyName];
|
||||||
|
}
|
||||||
|
|
||||||
|
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function _arrayMerge(_ref, target, source) {
|
function _arrayMerge(_ref, target, source) {
|
||||||
var component = _ref.component,
|
var component = _ref.component,
|
||||||
@@ -747,6 +742,11 @@ function merge(target, source) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getComponentMetaInfo() {
|
||||||
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
|
var component = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
return getComponentOption(options, component, defaultInfo);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the `opts.option` $option value of the given `opts.component`.
|
* Returns the `opts.option` $option value of the given `opts.component`.
|
||||||
* If methods are encountered, they will be bound to the component context.
|
* If methods are encountered, they will be bound to the component context.
|
||||||
@@ -835,12 +835,12 @@ function getComponentOption() {
|
|||||||
|
|
||||||
function getMetaInfo() {
|
function getMetaInfo() {
|
||||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
var component = arguments.length > 1 ? arguments[1] : undefined;
|
var info = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
// collect & aggregate all metaInfo $options
|
var component = arguments.length > 3 ? arguments[3] : undefined;
|
||||||
var info = getComponentOption(options, component, defaultInfo); // Remove all "template" tags from meta
|
|
||||||
// backup the title chunk in case user wants access to it
|
|
||||||
|
|
||||||
|
// Remove all "template" tags from meta
|
||||||
|
// backup the title chunk in case user wants access to it
|
||||||
if (info.title) {
|
if (info.title) {
|
||||||
info.titleChunk = info.title;
|
info.titleChunk = info.title;
|
||||||
} // replace title with populated template
|
} // replace title with populated template
|
||||||
@@ -859,31 +859,7 @@ function getMetaInfo() {
|
|||||||
info.base = Object.keys(info.base).length ? [info.base] : [];
|
info.base = Object.keys(info.base).length ? [info.base] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var escapeOptions = {
|
return escapeMetaInfo(options, info, escapeSequences);
|
||||||
doEscape: function doEscape(value) {
|
|
||||||
return escapeSequences.reduce(function (val, _ref) {
|
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
|
||||||
v = _ref2[0],
|
|
||||||
r = _ref2[1];
|
|
||||||
|
|
||||||
return val.replace(v, r);
|
|
||||||
}, value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
disableOptionKeys.forEach(function (disableKey, index) {
|
|
||||||
if (index === 0) {
|
|
||||||
ensureIsArray(info, disableKey);
|
|
||||||
} else if (index === 1) {
|
|
||||||
for (var key in info[disableKey]) {
|
|
||||||
ensureIsArray(info[disableKey], key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
escapeOptions[disableKey] = info[disableKey];
|
|
||||||
}); // begin sanitization
|
|
||||||
|
|
||||||
info = escape(info, options, escapeOptions);
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTag(tags, tag) {
|
function getTag(tags, tag) {
|
||||||
@@ -932,35 +908,14 @@ function addCallback(query, callback) {
|
|||||||
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
||||||
var tagIDKeyName = _ref.tagIDKeyName;
|
var tagIDKeyName = _ref.tagIDKeyName;
|
||||||
var hasAsyncCallback = false;
|
var hasAsyncCallback = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tags.forEach(function (tag) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (!tag[tagIDKeyName] || !tag.callback) {
|
if (!tag[tagIDKeyName] || !tag.callback) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAsyncCallback = true;
|
hasAsyncCallback = true;
|
||||||
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!autoAddListeners || !hasAsyncCallback) {
|
if (!autoAddListeners || !hasAsyncCallback) {
|
||||||
return hasAsyncCallback;
|
return hasAsyncCallback;
|
||||||
@@ -982,10 +937,10 @@ function addListeners() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
function applyCallbacks(matchElement) {
|
function applyCallbacks(matchElement) {
|
||||||
var _loop = function _loop() {
|
callbacks.forEach(function (_ref2) {
|
||||||
var _callbacks$_i = _slicedToArray(_callbacks[_i], 2),
|
var _ref3 = _slicedToArray(_ref2, 2),
|
||||||
query = _callbacks$_i[0],
|
query = _ref3[0],
|
||||||
callback = _callbacks$_i[1];
|
callback = _ref3[1];
|
||||||
|
|
||||||
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
||||||
var elements = [];
|
var elements = [];
|
||||||
@@ -998,20 +953,13 @@ function applyCallbacks(matchElement) {
|
|||||||
elements = [matchElement];
|
elements = [matchElement];
|
||||||
}
|
}
|
||||||
|
|
||||||
var _iteratorNormalCompletion2 = true;
|
elements.forEach(function (element) {
|
||||||
var _didIteratorError2 = false;
|
|
||||||
var _iteratorError2 = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop2 = function _loop2() {
|
|
||||||
var element = _step2.value;
|
|
||||||
|
|
||||||
/* __vm_cb: whether the load callback has been called
|
/* __vm_cb: whether the load callback has been called
|
||||||
* __vm_l: set by onload attribute, whether the element was loaded
|
* __vm_l: set by onload attribute, whether the element was loaded
|
||||||
* __vm_ev: whether the event listener was added or not
|
* __vm_ev: whether the event listener was added or not
|
||||||
*/
|
*/
|
||||||
if (element.__vm_cb) {
|
if (element.__vm_cb) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var onload = function onload() {
|
var onload = function onload() {
|
||||||
@@ -1038,39 +986,15 @@ function applyCallbacks(matchElement) {
|
|||||||
|
|
||||||
if (element.__vm_l) {
|
if (element.__vm_l) {
|
||||||
onload();
|
onload();
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!element.__vm_ev) {
|
if (!element.__vm_ev) {
|
||||||
element.__vm_ev = true;
|
element.__vm_ev = true;
|
||||||
element.addEventListener('load', onload);
|
element.addEventListener('load', onload);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
});
|
||||||
for (var _iterator2 = elements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
||||||
var _ret = _loop2();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError2 = true;
|
|
||||||
_iteratorError2 = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
||||||
_iterator2.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError2) {
|
|
||||||
throw _iteratorError2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
||||||
_loop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1149,7 +1073,8 @@ function updateTag(appId) {
|
|||||||
var body = arguments.length > 5 ? arguments[5] : undefined;
|
var body = arguments.length > 5 ? arguments[5] : undefined;
|
||||||
var attribute = options.attribute,
|
var attribute = options.attribute,
|
||||||
tagIDKeyName = options.tagIDKeyName;
|
tagIDKeyName = options.tagIDKeyName;
|
||||||
var dataAttributes = [tagIDKeyName].concat(_toConsumableArray(commonDataAttributes));
|
var dataAttributes = commonDataAttributes.slice();
|
||||||
|
dataAttributes.push(tagIDKeyName);
|
||||||
var newElements = [];
|
var newElements = [];
|
||||||
var queryOptions = {
|
var queryOptions = {
|
||||||
appId: appId,
|
appId: appId,
|
||||||
@@ -1180,23 +1105,15 @@ function updateTag(appId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.length) {
|
tags.forEach(function (tag) {
|
||||||
var _iteratorNormalCompletion = true;
|
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop = function _loop() {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (tag.skip) {
|
if (tag.skip) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newElement = document.createElement(type);
|
var newElement = document.createElement(type);
|
||||||
newElement.setAttribute(attribute, appId);
|
newElement.setAttribute(attribute, appId);
|
||||||
|
|
||||||
var _loop2 = function _loop2(attr) {
|
var _loop = function _loop(attr) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!tag.hasOwnProperty(attr)) {
|
if (!tag.hasOwnProperty(attr)) {
|
||||||
return "continue";
|
return "continue";
|
||||||
@@ -1244,14 +1161,14 @@ function updateTag(appId) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (var attr in tag) {
|
for (var attr in tag) {
|
||||||
var _ret2 = _loop2(attr);
|
var _ret = _loop(attr);
|
||||||
|
|
||||||
if (_ret2 === "continue") continue;
|
if (_ret === "continue") continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
||||||
|
|
||||||
var indexToDelete = void 0;
|
var indexToDelete;
|
||||||
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
||||||
indexToDelete = index;
|
indexToDelete = index;
|
||||||
return newElement.isEqualNode(existingTag);
|
return newElement.isEqualNode(existingTag);
|
||||||
@@ -1262,59 +1179,31 @@ function updateTag(appId) {
|
|||||||
} else {
|
} else {
|
||||||
newElements.push(newElement);
|
newElements.push(newElement);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var _ret = _loop();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var oldElements = [];
|
var oldElements = [];
|
||||||
|
|
||||||
for (var _i = 0, _Object$values = Object.values(currentElements); _i < _Object$values.length; _i++) {
|
for (var _type in currentElements) {
|
||||||
var current = _Object$values[_i];
|
Array.prototype.push.apply(oldElements, currentElements[_type]);
|
||||||
oldElements = [].concat(_toConsumableArray(oldElements), _toConsumableArray(current));
|
|
||||||
} // remove old elements
|
} // remove old elements
|
||||||
|
|
||||||
|
|
||||||
for (var _i2 = 0, _oldElements = oldElements; _i2 < _oldElements.length; _i2++) {
|
oldElements.forEach(function (element) {
|
||||||
var element = _oldElements[_i2];
|
|
||||||
element.parentNode.removeChild(element);
|
element.parentNode.removeChild(element);
|
||||||
} // insert new elements
|
}); // insert new elements
|
||||||
|
|
||||||
|
newElements.forEach(function (element) {
|
||||||
for (var _i3 = 0, _newElements = newElements; _i3 < _newElements.length; _i3++) {
|
if (element.hasAttribute('data-body')) {
|
||||||
var _element = _newElements[_i3];
|
body.appendChild(element);
|
||||||
|
return;
|
||||||
if (_element.hasAttribute('data-body')) {
|
|
||||||
body.appendChild(_element);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_element.hasAttribute('data-pbody')) {
|
if (element.hasAttribute('data-pbody')) {
|
||||||
body.insertBefore(_element, body.firstChild);
|
body.insertBefore(element, body.firstChild);
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
head.appendChild(_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
head.appendChild(element);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
oldTags: oldElements,
|
oldTags: oldElements,
|
||||||
newTags: newElements
|
newTags: newElements
|
||||||
@@ -1341,32 +1230,11 @@ function updateClientMetaInfo(appId) {
|
|||||||
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
||||||
|
|
||||||
var addLoadListeners = false;
|
var addLoadListeners = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tagsSupportingOnload.forEach(function (type) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tagsSupportingOnload[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var type = _step.value;
|
|
||||||
|
|
||||||
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
||||||
addLoadListeners = true;
|
addLoadListeners = true;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addLoadListeners) {
|
if (addLoadListeners) {
|
||||||
addListeners();
|
addListeners();
|
||||||
@@ -1379,37 +1247,36 @@ function updateClientMetaInfo(appId) {
|
|||||||
var addedTags = {};
|
var addedTags = {};
|
||||||
var removedTags = {};
|
var removedTags = {};
|
||||||
|
|
||||||
for (var _type in newInfo) {
|
for (var type in newInfo) {
|
||||||
// ignore these
|
// ignore these
|
||||||
if (includes(metaInfoOptionKeys, _type)) {
|
if (includes(metaInfoOptionKeys, type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_type === 'title') {
|
if (type === 'title') {
|
||||||
// update the title
|
// update the title
|
||||||
updateTitle(newInfo.title);
|
updateTitle(newInfo.title);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includes(metaInfoAttributeKeys, _type)) {
|
if (includes(metaInfoAttributeKeys, type)) {
|
||||||
var tagName = _type.substr(0, 4);
|
var tagName = type.substr(0, 4);
|
||||||
|
updateAttribute(options, newInfo[type], getTag(tags, tagName));
|
||||||
updateAttribute(options, newInfo[_type], getTag(tags, tagName));
|
|
||||||
continue;
|
continue;
|
||||||
} // tags should always be an array, ignore if it isnt
|
} // tags should always be an array, ignore if it isnt
|
||||||
|
|
||||||
|
|
||||||
if (!isArray(newInfo[_type])) {
|
if (!isArray(newInfo[type])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _updateTag = updateTag(appId, options, _type, newInfo[_type], getTag(tags, 'head'), getTag(tags, 'body')),
|
var _updateTag = updateTag(appId, options, type, newInfo[type], getTag(tags, 'head'), getTag(tags, 'body')),
|
||||||
oldTags = _updateTag.oldTags,
|
oldTags = _updateTag.oldTags,
|
||||||
newTags = _updateTag.newTags;
|
newTags = _updateTag.newTags;
|
||||||
|
|
||||||
if (newTags.length) {
|
if (newTags.length) {
|
||||||
addedTags[_type] = newTags;
|
addedTags[type] = newTags;
|
||||||
removedTags[_type] = oldTags;
|
removedTags[type] = oldTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1433,7 +1300,9 @@ function _refresh() {
|
|||||||
* @return {Object} - new meta info
|
* @return {Object} - new meta info
|
||||||
*/
|
*/
|
||||||
return function refresh() {
|
return function refresh() {
|
||||||
var metaInfo = getMetaInfo(options, this.$root, clientSequences);
|
// collect & aggregate all metaInfo $options
|
||||||
|
var rawInfo = getComponentMetaInfo(options, this.$root);
|
||||||
|
var metaInfo = getMetaInfo(options, rawInfo, clientSequences, this.$root);
|
||||||
var appId = this.$root._vueMeta.appId;
|
var appId = this.$root._vueMeta.appId;
|
||||||
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
||||||
|
|
||||||
@@ -1530,7 +1399,7 @@ function tagGenerator() {
|
|||||||
|
|
||||||
var type = arguments.length > 1 ? arguments[1] : undefined;
|
var type = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
var tags = arguments.length > 2 ? arguments[2] : undefined;
|
var tags = arguments.length > 2 ? arguments[2] : undefined;
|
||||||
var dataAttributes = [tagIDKeyName, 'callback'].concat(_toConsumableArray(commonDataAttributes));
|
var dataAttributes = [tagIDKeyName].concat(_toConsumableArray(commonDataAttributes));
|
||||||
return {
|
return {
|
||||||
text: function text() {
|
text: function text() {
|
||||||
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
||||||
@@ -1539,7 +1408,11 @@ function tagGenerator() {
|
|||||||
_ref2$pbody = _ref2.pbody,
|
_ref2$pbody = _ref2.pbody,
|
||||||
pbody = _ref2$pbody === void 0 ? false : _ref2$pbody;
|
pbody = _ref2$pbody === void 0 ? false : _ref2$pbody;
|
||||||
|
|
||||||
// build a string containing all tags of this type
|
if (!tags || !tags.length) {
|
||||||
|
return '';
|
||||||
|
} // build a string containing all tags of this type
|
||||||
|
|
||||||
|
|
||||||
return tags.reduce(function (tagsStr, tag) {
|
return tags.reduce(function (tagsStr, tag) {
|
||||||
if (tag.skip) {
|
if (tag.skip) {
|
||||||
return tagsStr;
|
return tagsStr;
|
||||||
@@ -1561,6 +1434,11 @@ function tagGenerator() {
|
|||||||
// these attributes are treated as children on the tag
|
// these attributes are treated as children on the tag
|
||||||
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
|
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attr === 'callback') {
|
||||||
|
attrs += " onload=\"this.__vm_l=1\"";
|
||||||
|
continue;
|
||||||
} // these form the attribute list for this tag
|
} // these form the attribute list for this tag
|
||||||
|
|
||||||
|
|
||||||
@@ -1570,11 +1448,6 @@ function tagGenerator() {
|
|||||||
prefix = 'data-';
|
prefix = 'data-';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attr === 'callback') {
|
|
||||||
attrs += " onload=\"this.__vm_l=1\"";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var isBooleanAttr = !prefix && booleanHtmlAttributes.includes(attr);
|
var isBooleanAttr = !prefix && booleanHtmlAttributes.includes(attr);
|
||||||
|
|
||||||
if (isBooleanAttr && !tag[attr]) {
|
if (isBooleanAttr && !tag[attr]) {
|
||||||
@@ -1612,16 +1485,26 @@ function tagGenerator() {
|
|||||||
* @return {Object} - the new injector
|
* @return {Object} - the new injector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function generateServerInjector(options, type, data) {
|
function generateServerInjector(options, newInfo) {
|
||||||
|
for (var type in defaultInfo) {
|
||||||
|
if (metaInfoOptionKeys.includes(type)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'title') {
|
if (type === 'title') {
|
||||||
return titleGenerator(options, type, data);
|
newInfo[type] = titleGenerator(options, type, newInfo[type]);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metaInfoAttributeKeys.includes(type)) {
|
if (metaInfoAttributeKeys.includes(type)) {
|
||||||
return attributeGenerator(options, type, data);
|
newInfo[type] = attributeGenerator(options, type, newInfo[type]);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tagGenerator(options, type, data);
|
newInfo[type] = tagGenerator(options, type, newInfo[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _inject() {
|
function _inject() {
|
||||||
@@ -1635,15 +1518,11 @@ function _inject() {
|
|||||||
* @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
|
// collect & aggregate all metaInfo $options
|
||||||
var metaInfo = getMetaInfo(options, this.$root, serverSequences); // generate server injectors
|
var rawInfo = getComponentMetaInfo(options, this.$root);
|
||||||
|
var metaInfo = getMetaInfo(options, rawInfo, serverSequences, this.$root); // generate server injectors
|
||||||
for (var key in metaInfo) {
|
|
||||||
if (!metaInfoOptionKeys.includes(key) && metaInfo.hasOwnProperty(key)) {
|
|
||||||
metaInfo[key] = generateServerInjector(options, key, metaInfo[key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
generateServerInjector(options, metaInfo);
|
||||||
return metaInfo;
|
return metaInfo;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1674,6 +1553,12 @@ function _$meta() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generate(rawInfo) {
|
||||||
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||||
|
var metaInfo = getMetaInfo(setOptions(options), rawInfo, serverSequences);
|
||||||
|
return generateServerInjector(options, metaInfo);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin install function.
|
* Plugin install function.
|
||||||
* @param {Function} Vue - the Vue constructor.
|
* @param {Function} Vue - the Vue constructor.
|
||||||
@@ -1695,7 +1580,8 @@ function install(Vue) {
|
|||||||
var index = {
|
var index = {
|
||||||
version: version,
|
version: version,
|
||||||
install: install,
|
install: install,
|
||||||
hasMetaInfo: hasMetaInfo
|
hasMetaInfo: hasMetaInfo,
|
||||||
|
generate: generate
|
||||||
};
|
};
|
||||||
|
|
||||||
export default index;
|
export default index;
|
||||||
|
|||||||
Vendored
+139
-290
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vue-meta v2.1.1
|
* vue-meta v2.2.0
|
||||||
* (c) 2019
|
* (c) 2019
|
||||||
* - Declan de Wet
|
* - Declan de Wet
|
||||||
* - Sébastien Chopin (@Atinux)
|
* - Sébastien Chopin (@Atinux)
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
(global = global || self, global.VueMeta = factory());
|
(global = global || self, global.VueMeta = factory());
|
||||||
}(this, function () { 'use strict';
|
}(this, function () { 'use strict';
|
||||||
|
|
||||||
var version = "2.1.1";
|
var version = "2.2.0";
|
||||||
|
|
||||||
// store an id to keep track of DOM updates
|
// store an id to keep track of DOM updates
|
||||||
var batchId = null;
|
var batchId = null;
|
||||||
@@ -63,79 +63,14 @@
|
|||||||
return _typeof(obj);
|
return _typeof(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _defineProperty(obj, key, value) {
|
|
||||||
if (key in obj) {
|
|
||||||
Object.defineProperty(obj, key, {
|
|
||||||
value: value,
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true,
|
|
||||||
writable: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
obj[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ownKeys(object, enumerableOnly) {
|
|
||||||
var keys = Object.keys(object);
|
|
||||||
|
|
||||||
if (Object.getOwnPropertySymbols) {
|
|
||||||
var symbols = Object.getOwnPropertySymbols(object);
|
|
||||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
||||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
||||||
});
|
|
||||||
keys.push.apply(keys, symbols);
|
|
||||||
}
|
|
||||||
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _objectSpread2(target) {
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
|
||||||
var source = arguments[i] != null ? arguments[i] : {};
|
|
||||||
|
|
||||||
if (i % 2) {
|
|
||||||
ownKeys(source, true).forEach(function (key) {
|
|
||||||
_defineProperty(target, key, source[key]);
|
|
||||||
});
|
|
||||||
} else if (Object.getOwnPropertyDescriptors) {
|
|
||||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
||||||
} else {
|
|
||||||
ownKeys(source).forEach(function (key) {
|
|
||||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
function _slicedToArray(arr, i) {
|
function _slicedToArray(arr, i) {
|
||||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _toConsumableArray(arr) {
|
|
||||||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
|
||||||
}
|
|
||||||
|
|
||||||
function _arrayWithoutHoles(arr) {
|
|
||||||
if (Array.isArray(arr)) {
|
|
||||||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
||||||
|
|
||||||
return arr2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _arrayWithHoles(arr) {
|
function _arrayWithHoles(arr) {
|
||||||
if (Array.isArray(arr)) return arr;
|
if (Array.isArray(arr)) return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _iterableToArray(iter) {
|
|
||||||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _iterableToArrayLimit(arr, i) {
|
function _iterableToArrayLimit(arr, i) {
|
||||||
var _arr = [];
|
var _arr = [];
|
||||||
var _n = true;
|
var _n = true;
|
||||||
@@ -162,10 +97,6 @@
|
|||||||
return _arr;
|
return _arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _nonIterableSpread() {
|
|
||||||
throw new TypeError("Invalid attempt to spread non-iterable instance");
|
|
||||||
}
|
|
||||||
|
|
||||||
function _nonIterableRest() {
|
function _nonIterableRest() {
|
||||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||||
}
|
}
|
||||||
@@ -256,13 +187,13 @@
|
|||||||
var _global = hasGlobalWindow ? window : global;
|
var _global = hasGlobalWindow ? window : global;
|
||||||
|
|
||||||
var console = _global.console = _global.console || {};
|
var console = _global.console = _global.console || {};
|
||||||
function warn() {
|
function warn(str) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!console || !console.warn) {
|
if (!console || !console.warn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn.apply(console, arguments);
|
console.warn(str);
|
||||||
}
|
}
|
||||||
var showWarningNotSupported = function showWarningNotSupported() {
|
var showWarningNotSupported = function showWarningNotSupported() {
|
||||||
return warn('This vue app/component has no vue-meta configuration');
|
return warn('This vue app/component has no vue-meta configuration');
|
||||||
@@ -527,29 +458,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTemplate(_ref, headObject, template, chunk) {
|
|
||||||
var component = _ref.component,
|
|
||||||
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
|
||||||
contentKeyName = _ref.contentKeyName;
|
|
||||||
|
|
||||||
if (isUndefined(template)) {
|
|
||||||
template = headObject[metaTemplateKeyName];
|
|
||||||
delete headObject[metaTemplateKeyName];
|
|
||||||
} // return early if no template defined
|
|
||||||
|
|
||||||
|
|
||||||
if (!template) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isUndefined(chunk)) {
|
|
||||||
chunk = headObject[contentKeyName];
|
|
||||||
}
|
|
||||||
|
|
||||||
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To reduce build size, this file provides simple polyfills without
|
* To reduce build size, this file provides simple polyfills without
|
||||||
* overly excessive type checking and without modifying
|
* overly excessive type checking and without modifying
|
||||||
@@ -559,27 +467,48 @@
|
|||||||
* files in server/ still use normal js function
|
* files in server/ still use normal js function
|
||||||
*/
|
*/
|
||||||
function findIndex(array, predicate) {
|
function findIndex(array, predicate) {
|
||||||
|
if ( !Array.prototype.findIndex) {
|
||||||
|
// idx needs to be a Number, for..in returns string
|
||||||
|
for (var idx = 0; idx < array.length; idx++) {
|
||||||
|
if (predicate.call(arguments[2], array[idx], idx, array)) {
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return array.findIndex(predicate, arguments[2]);
|
return array.findIndex(predicate, arguments[2]);
|
||||||
}
|
}
|
||||||
function toArray(arg) {
|
function toArray(arg) {
|
||||||
|
if ( !Array.from) {
|
||||||
|
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) {
|
||||||
|
for (var idx in array) {
|
||||||
|
if (array[idx] === value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return array.includes(value);
|
return array.includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
var clientSequences = [[/&/g, "&"], [/</g, "<"], [/>/g, ">"], [/"/g, "\""], [/'/g, "'"]]; // sanitizes potentially dangerous characters
|
||||||
|
|
||||||
function escape(info, options, escapeOptions) {
|
function escape(info, options, escapeOptions, escapeKeys) {
|
||||||
var tagIDKeyName = options.tagIDKeyName;
|
var tagIDKeyName = options.tagIDKeyName;
|
||||||
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
var _escapeOptions$doEsca = escapeOptions.doEscape,
|
||||||
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
doEscape = _escapeOptions$doEsca === void 0 ? function (v) {
|
||||||
return v;
|
return v;
|
||||||
} : _escapeOptions$doEsca,
|
} : _escapeOptions$doEsca;
|
||||||
escapeKeys = escapeOptions.escapeKeys;
|
|
||||||
var escaped = {};
|
var escaped = {};
|
||||||
|
|
||||||
for (var key in info) {
|
for (var key in info) {
|
||||||
@@ -615,17 +544,13 @@
|
|||||||
} else if (isArray(value)) {
|
} else if (isArray(value)) {
|
||||||
escaped[key] = value.map(function (v) {
|
escaped[key] = value.map(function (v) {
|
||||||
if (isPureObject(v)) {
|
if (isPureObject(v)) {
|
||||||
return escape(v, options, _objectSpread2({}, escapeOptions, {
|
return escape(v, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return doEscape(v);
|
return doEscape(v);
|
||||||
});
|
});
|
||||||
} else if (isPureObject(value)) {
|
} else if (isPureObject(value)) {
|
||||||
escaped[key] = escape(value, options, _objectSpread2({}, escapeOptions, {
|
escaped[key] = escape(value, options, escapeOptions, true);
|
||||||
escapeKeys: true
|
|
||||||
}));
|
|
||||||
} else {
|
} else {
|
||||||
escaped[key] = value;
|
escaped[key] = value;
|
||||||
}
|
}
|
||||||
@@ -642,6 +567,33 @@
|
|||||||
|
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
|
function escapeMetaInfo(options, info) {
|
||||||
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
|
var escapeOptions = {
|
||||||
|
doEscape: function doEscape(value) {
|
||||||
|
return escapeSequences.reduce(function (val, _ref) {
|
||||||
|
var _ref2 = _slicedToArray(_ref, 2),
|
||||||
|
v = _ref2[0],
|
||||||
|
r = _ref2[1];
|
||||||
|
|
||||||
|
return val.replace(v, r);
|
||||||
|
}, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
disableOptionKeys.forEach(function (disableKey, index) {
|
||||||
|
if (index === 0) {
|
||||||
|
ensureIsArray(info, disableKey);
|
||||||
|
} else if (index === 1) {
|
||||||
|
for (var key in info[disableKey]) {
|
||||||
|
ensureIsArray(info[disableKey], key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
escapeOptions[disableKey] = info[disableKey];
|
||||||
|
}); // begin sanitization
|
||||||
|
|
||||||
|
return escape(info, options, escapeOptions);
|
||||||
|
}
|
||||||
|
|
||||||
var isMergeableObject = function isMergeableObject(value) {
|
var isMergeableObject = function isMergeableObject(value) {
|
||||||
return isNonNullObject(value) && !isSpecial(value);
|
return isNonNullObject(value) && !isSpecial(value);
|
||||||
@@ -746,6 +698,29 @@
|
|||||||
var deepmerge_1 = deepmerge;
|
var deepmerge_1 = deepmerge;
|
||||||
var cjs = deepmerge_1;
|
var cjs = deepmerge_1;
|
||||||
|
|
||||||
|
function applyTemplate(_ref, headObject, template, chunk) {
|
||||||
|
var component = _ref.component,
|
||||||
|
metaTemplateKeyName = _ref.metaTemplateKeyName,
|
||||||
|
contentKeyName = _ref.contentKeyName;
|
||||||
|
|
||||||
|
if (isUndefined(template)) {
|
||||||
|
template = headObject[metaTemplateKeyName];
|
||||||
|
delete headObject[metaTemplateKeyName];
|
||||||
|
} // return early if no template defined
|
||||||
|
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUndefined(chunk)) {
|
||||||
|
chunk = headObject[contentKeyName];
|
||||||
|
}
|
||||||
|
|
||||||
|
headObject[contentKeyName] = isFunction(template) ? template.call(component, chunk) : template.replace(/%s/g, chunk);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function _arrayMerge(_ref, target, source) {
|
function _arrayMerge(_ref, target, source) {
|
||||||
var component = _ref.component,
|
var component = _ref.component,
|
||||||
tagIDKeyName = _ref.tagIDKeyName,
|
tagIDKeyName = _ref.tagIDKeyName,
|
||||||
@@ -849,6 +824,11 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getComponentMetaInfo() {
|
||||||
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
|
var component = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
|
return getComponentOption(options, component, defaultInfo);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the `opts.option` $option value of the given `opts.component`.
|
* Returns the `opts.option` $option value of the given `opts.component`.
|
||||||
* If methods are encountered, they will be bound to the component context.
|
* If methods are encountered, they will be bound to the component context.
|
||||||
@@ -937,12 +917,12 @@
|
|||||||
|
|
||||||
function getMetaInfo() {
|
function getMetaInfo() {
|
||||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||||
var component = arguments.length > 1 ? arguments[1] : undefined;
|
var info = arguments.length > 1 ? arguments[1] : undefined;
|
||||||
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
var escapeSequences = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
||||||
// collect & aggregate all metaInfo $options
|
var component = arguments.length > 3 ? arguments[3] : undefined;
|
||||||
var info = getComponentOption(options, component, defaultInfo); // Remove all "template" tags from meta
|
|
||||||
// backup the title chunk in case user wants access to it
|
|
||||||
|
|
||||||
|
// Remove all "template" tags from meta
|
||||||
|
// backup the title chunk in case user wants access to it
|
||||||
if (info.title) {
|
if (info.title) {
|
||||||
info.titleChunk = info.title;
|
info.titleChunk = info.title;
|
||||||
} // replace title with populated template
|
} // replace title with populated template
|
||||||
@@ -961,31 +941,7 @@
|
|||||||
info.base = Object.keys(info.base).length ? [info.base] : [];
|
info.base = Object.keys(info.base).length ? [info.base] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var escapeOptions = {
|
return escapeMetaInfo(options, info, escapeSequences);
|
||||||
doEscape: function doEscape(value) {
|
|
||||||
return escapeSequences.reduce(function (val, _ref) {
|
|
||||||
var _ref2 = _slicedToArray(_ref, 2),
|
|
||||||
v = _ref2[0],
|
|
||||||
r = _ref2[1];
|
|
||||||
|
|
||||||
return val.replace(v, r);
|
|
||||||
}, value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
disableOptionKeys.forEach(function (disableKey, index) {
|
|
||||||
if (index === 0) {
|
|
||||||
ensureIsArray(info, disableKey);
|
|
||||||
} else if (index === 1) {
|
|
||||||
for (var key in info[disableKey]) {
|
|
||||||
ensureIsArray(info[disableKey], key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
escapeOptions[disableKey] = info[disableKey];
|
|
||||||
}); // begin sanitization
|
|
||||||
|
|
||||||
info = escape(info, options, escapeOptions);
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTag(tags, tag) {
|
function getTag(tags, tag) {
|
||||||
@@ -1034,35 +990,14 @@
|
|||||||
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
function addCallbacks(_ref, type, tags, autoAddListeners) {
|
||||||
var tagIDKeyName = _ref.tagIDKeyName;
|
var tagIDKeyName = _ref.tagIDKeyName;
|
||||||
var hasAsyncCallback = false;
|
var hasAsyncCallback = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tags.forEach(function (tag) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (!tag[tagIDKeyName] || !tag.callback) {
|
if (!tag[tagIDKeyName] || !tag.callback) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasAsyncCallback = true;
|
hasAsyncCallback = true;
|
||||||
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
addCallback("".concat(type, "[data-").concat(tagIDKeyName, "=\"").concat(tag[tagIDKeyName], "\"]"), tag.callback);
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!autoAddListeners || !hasAsyncCallback) {
|
if (!autoAddListeners || !hasAsyncCallback) {
|
||||||
return hasAsyncCallback;
|
return hasAsyncCallback;
|
||||||
@@ -1084,10 +1019,10 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
function applyCallbacks(matchElement) {
|
function applyCallbacks(matchElement) {
|
||||||
var _loop = function _loop() {
|
callbacks.forEach(function (_ref2) {
|
||||||
var _callbacks$_i = _slicedToArray(_callbacks[_i], 2),
|
var _ref3 = _slicedToArray(_ref2, 2),
|
||||||
query = _callbacks$_i[0],
|
query = _ref3[0],
|
||||||
callback = _callbacks$_i[1];
|
callback = _ref3[1];
|
||||||
|
|
||||||
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
var selector = "".concat(query, "[onload=\"this.__vm_l=1\"]");
|
||||||
var elements = [];
|
var elements = [];
|
||||||
@@ -1100,20 +1035,13 @@
|
|||||||
elements = [matchElement];
|
elements = [matchElement];
|
||||||
}
|
}
|
||||||
|
|
||||||
var _iteratorNormalCompletion2 = true;
|
elements.forEach(function (element) {
|
||||||
var _didIteratorError2 = false;
|
|
||||||
var _iteratorError2 = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop2 = function _loop2() {
|
|
||||||
var element = _step2.value;
|
|
||||||
|
|
||||||
/* __vm_cb: whether the load callback has been called
|
/* __vm_cb: whether the load callback has been called
|
||||||
* __vm_l: set by onload attribute, whether the element was loaded
|
* __vm_l: set by onload attribute, whether the element was loaded
|
||||||
* __vm_ev: whether the event listener was added or not
|
* __vm_ev: whether the event listener was added or not
|
||||||
*/
|
*/
|
||||||
if (element.__vm_cb) {
|
if (element.__vm_cb) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var onload = function onload() {
|
var onload = function onload() {
|
||||||
@@ -1140,39 +1068,15 @@
|
|||||||
|
|
||||||
if (element.__vm_l) {
|
if (element.__vm_l) {
|
||||||
onload();
|
onload();
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!element.__vm_ev) {
|
if (!element.__vm_ev) {
|
||||||
element.__vm_ev = true;
|
element.__vm_ev = true;
|
||||||
element.addEventListener('load', onload);
|
element.addEventListener('load', onload);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
});
|
||||||
for (var _iterator2 = elements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
||||||
var _ret = _loop2();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError2 = true;
|
|
||||||
_iteratorError2 = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
||||||
_iterator2.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError2) {
|
|
||||||
throw _iteratorError2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
||||||
_loop();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1251,7 +1155,8 @@
|
|||||||
var body = arguments.length > 5 ? arguments[5] : undefined;
|
var body = arguments.length > 5 ? arguments[5] : undefined;
|
||||||
var attribute = options.attribute,
|
var attribute = options.attribute,
|
||||||
tagIDKeyName = options.tagIDKeyName;
|
tagIDKeyName = options.tagIDKeyName;
|
||||||
var dataAttributes = [tagIDKeyName].concat(_toConsumableArray(commonDataAttributes));
|
var dataAttributes = commonDataAttributes.slice();
|
||||||
|
dataAttributes.push(tagIDKeyName);
|
||||||
var newElements = [];
|
var newElements = [];
|
||||||
var queryOptions = {
|
var queryOptions = {
|
||||||
appId: appId,
|
appId: appId,
|
||||||
@@ -1282,23 +1187,15 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.length) {
|
tags.forEach(function (tag) {
|
||||||
var _iteratorNormalCompletion = true;
|
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
var _loop = function _loop() {
|
|
||||||
var tag = _step.value;
|
|
||||||
|
|
||||||
if (tag.skip) {
|
if (tag.skip) {
|
||||||
return "continue";
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var newElement = document.createElement(type);
|
var newElement = document.createElement(type);
|
||||||
newElement.setAttribute(attribute, appId);
|
newElement.setAttribute(attribute, appId);
|
||||||
|
|
||||||
var _loop2 = function _loop2(attr) {
|
var _loop = function _loop(attr) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
if (!tag.hasOwnProperty(attr)) {
|
if (!tag.hasOwnProperty(attr)) {
|
||||||
return "continue";
|
return "continue";
|
||||||
@@ -1346,14 +1243,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (var attr in tag) {
|
for (var attr in tag) {
|
||||||
var _ret2 = _loop2(attr);
|
var _ret = _loop(attr);
|
||||||
|
|
||||||
if (_ret2 === "continue") continue;
|
if (_ret === "continue") continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
var oldElements = currentElements[getElementsKey(tag)]; // Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
|
||||||
|
|
||||||
var indexToDelete = void 0;
|
var indexToDelete;
|
||||||
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
var hasEqualElement = oldElements.some(function (existingTag, index) {
|
||||||
indexToDelete = index;
|
indexToDelete = index;
|
||||||
return newElement.isEqualNode(existingTag);
|
return newElement.isEqualNode(existingTag);
|
||||||
@@ -1364,59 +1261,31 @@
|
|||||||
} else {
|
} else {
|
||||||
newElements.push(newElement);
|
newElements.push(newElement);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
for (var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var _ret = _loop();
|
|
||||||
|
|
||||||
if (_ret === "continue") continue;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var oldElements = [];
|
var oldElements = [];
|
||||||
|
|
||||||
for (var _i = 0, _Object$values = Object.values(currentElements); _i < _Object$values.length; _i++) {
|
for (var _type in currentElements) {
|
||||||
var current = _Object$values[_i];
|
Array.prototype.push.apply(oldElements, currentElements[_type]);
|
||||||
oldElements = [].concat(_toConsumableArray(oldElements), _toConsumableArray(current));
|
|
||||||
} // remove old elements
|
} // remove old elements
|
||||||
|
|
||||||
|
|
||||||
for (var _i2 = 0, _oldElements = oldElements; _i2 < _oldElements.length; _i2++) {
|
oldElements.forEach(function (element) {
|
||||||
var element = _oldElements[_i2];
|
|
||||||
element.parentNode.removeChild(element);
|
element.parentNode.removeChild(element);
|
||||||
} // insert new elements
|
}); // insert new elements
|
||||||
|
|
||||||
|
newElements.forEach(function (element) {
|
||||||
for (var _i3 = 0, _newElements = newElements; _i3 < _newElements.length; _i3++) {
|
if (element.hasAttribute('data-body')) {
|
||||||
var _element = _newElements[_i3];
|
body.appendChild(element);
|
||||||
|
return;
|
||||||
if (_element.hasAttribute('data-body')) {
|
|
||||||
body.appendChild(_element);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_element.hasAttribute('data-pbody')) {
|
if (element.hasAttribute('data-pbody')) {
|
||||||
body.insertBefore(_element, body.firstChild);
|
body.insertBefore(element, body.firstChild);
|
||||||
continue;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
head.appendChild(_element);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
head.appendChild(element);
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
oldTags: oldElements,
|
oldTags: oldElements,
|
||||||
newTags: newElements
|
newTags: newElements
|
||||||
@@ -1443,32 +1312,11 @@
|
|||||||
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
htmlTag.removeAttribute(ssrAttribute); // add load callbacks if the
|
||||||
|
|
||||||
var addLoadListeners = false;
|
var addLoadListeners = false;
|
||||||
var _iteratorNormalCompletion = true;
|
tagsSupportingOnload.forEach(function (type) {
|
||||||
var _didIteratorError = false;
|
|
||||||
var _iteratorError = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator = tagsSupportingOnload[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
||||||
var type = _step.value;
|
|
||||||
|
|
||||||
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
if (newInfo[type] && addCallbacks(options, type, newInfo[type])) {
|
||||||
addLoadListeners = true;
|
addLoadListeners = true;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError = true;
|
|
||||||
_iteratorError = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
||||||
_iterator.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError) {
|
|
||||||
throw _iteratorError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addLoadListeners) {
|
if (addLoadListeners) {
|
||||||
addListeners();
|
addListeners();
|
||||||
@@ -1481,37 +1329,36 @@
|
|||||||
var addedTags = {};
|
var addedTags = {};
|
||||||
var removedTags = {};
|
var removedTags = {};
|
||||||
|
|
||||||
for (var _type in newInfo) {
|
for (var type in newInfo) {
|
||||||
// ignore these
|
// ignore these
|
||||||
if (includes(metaInfoOptionKeys, _type)) {
|
if (includes(metaInfoOptionKeys, type)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_type === 'title') {
|
if (type === 'title') {
|
||||||
// update the title
|
// update the title
|
||||||
updateTitle(newInfo.title);
|
updateTitle(newInfo.title);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includes(metaInfoAttributeKeys, _type)) {
|
if (includes(metaInfoAttributeKeys, type)) {
|
||||||
var tagName = _type.substr(0, 4);
|
var tagName = type.substr(0, 4);
|
||||||
|
updateAttribute(options, newInfo[type], getTag(tags, tagName));
|
||||||
updateAttribute(options, newInfo[_type], getTag(tags, tagName));
|
|
||||||
continue;
|
continue;
|
||||||
} // tags should always be an array, ignore if it isnt
|
} // tags should always be an array, ignore if it isnt
|
||||||
|
|
||||||
|
|
||||||
if (!isArray(newInfo[_type])) {
|
if (!isArray(newInfo[type])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var _updateTag = updateTag(appId, options, _type, newInfo[_type], getTag(tags, 'head'), getTag(tags, 'body')),
|
var _updateTag = updateTag(appId, options, type, newInfo[type], getTag(tags, 'head'), getTag(tags, 'body')),
|
||||||
oldTags = _updateTag.oldTags,
|
oldTags = _updateTag.oldTags,
|
||||||
newTags = _updateTag.newTags;
|
newTags = _updateTag.newTags;
|
||||||
|
|
||||||
if (newTags.length) {
|
if (newTags.length) {
|
||||||
addedTags[_type] = newTags;
|
addedTags[type] = newTags;
|
||||||
removedTags[_type] = oldTags;
|
removedTags[type] = oldTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1535,7 +1382,9 @@
|
|||||||
* @return {Object} - new meta info
|
* @return {Object} - new meta info
|
||||||
*/
|
*/
|
||||||
return function refresh() {
|
return function refresh() {
|
||||||
var metaInfo = getMetaInfo(options, this.$root, clientSequences);
|
// collect & aggregate all metaInfo $options
|
||||||
|
var rawInfo = getComponentMetaInfo(options, this.$root);
|
||||||
|
var metaInfo = getMetaInfo(options, rawInfo, clientSequences, this.$root);
|
||||||
var appId = this.$root._vueMeta.appId;
|
var appId = this.$root._vueMeta.appId;
|
||||||
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
var tags = updateClientMetaInfo(appId, options, metaInfo); // emit "event" with new info
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-meta",
|
"name": "vue-meta",
|
||||||
"version": "2.1.1",
|
"version": "2.2.0",
|
||||||
"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",
|
||||||
|
|||||||
Reference in New Issue
Block a user