'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var runtimeCore = require('@vue/runtime-core');
var shared = require('@vue/shared');
const svgNS = 'http://www.w3.org/2000/svg';
const doc = (typeof document !== 'undefined' ? document : null);
const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
const nodeOps = {
insert: (child, parent, anchor) => {
parent.insertBefore(child, anchor || null);
},
remove: child => {
const parent = child.parentNode;
if (parent) {
parent.removeChild(child);
}
},
createElement: (tag, isSVG, is, props) => {
const el = isSVG
? doc.createElementNS(svgNS, tag)
: doc.createElement(tag, is ? { is } : undefined);
if (tag === 'select' && props && props.multiple != null) {
el.setAttribute('multiple', props.multiple);
}
return el;
},
createText: text => doc.createTextNode(text),
createComment: text => doc.createComment(text),
setText: (node, text) => {
node.nodeValue = text;
},
setElementText: (el, text) => {
el.textContent = text;
},
parentNode: node => node.parentNode,
nextSibling: node => node.nextSibling,
querySelector: selector => doc.querySelector(selector),
setScopeId(el, id) {
el.setAttribute(id, '');
},
cloneNode(el) {
const cloned = el.cloneNode(true);
// #3072
// - in `patchDOMProp`, we store the actual value in the `el._value` property.
// - normally, elements using `:value` bindings will not be hoisted, but if
// the bound value is a constant, e.g. `:value="true"` - they do get
// hoisted.
// - in production, hoisted nodes are cloned when subsequent inserts, but
// cloneNode() does not copy the custom property we attached.
// - This may need to account for other custom DOM properties we attach to
// elements in addition to `_value` in the future.
if (`_value` in el) {
cloned._value = el._value;
}
return cloned;
},
// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
// As long as the user only uses trusted templates, this is safe.
insertStaticContent(content, parent, anchor, isSVG, start, end) {
// before | first ... last | anchor
const before = anchor ? anchor.previousSibling : parent.lastChild;
// #5308 can only take cached path if:
// - has a single root node
// - nextSibling info is still available
if (start && (start === end || start.nextSibling)) {
// cached
while (true) {
parent.insertBefore(start.cloneNode(true), anchor);
if (start === end || !(start = start.nextSibling))
break;
}
}
else {
// fresh insert
templateContainer.innerHTML = isSVG ? `` : content;
const template = templateContainer.content;
if (isSVG) {
// remove outer svg wrapper
const wrapper = template.firstChild;
while (wrapper.firstChild) {
template.appendChild(wrapper.firstChild);
}
template.removeChild(wrapper);
}
parent.insertBefore(template, anchor);
}
return [
// first
before ? before.nextSibling : parent.firstChild,
// last
anchor ? anchor.previousSibling : parent.lastChild
];
}
};
// compiler should normalize class + :class bindings on the same element
// into a single binding ['staticClass', dynamic]
function patchClass(el, value, isSVG) {
// directly setting className should be faster than setAttribute in theory
// if this is an element during a transition, take the temporary transition
// classes into account.
const transitionClasses = el._vtc;
if (transitionClasses) {
value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
}
if (value == null) {
el.removeAttribute('class');
}
else if (isSVG) {
el.setAttribute('class', value);
}
else {
el.className = value;
}
}
function patchStyle(el, prev, next) {
const style = el.style;
const isCssString = shared.isString(next);
if (next && !isCssString) {
for (const key in next) {
setStyle(style, key, next[key]);
}
if (prev && !shared.isString(prev)) {
for (const key in prev) {
if (next[key] == null) {
setStyle(style, key, '');
}
}
}
}
else {
const currentDisplay = style.display;
if (isCssString) {
if (prev !== next) {
style.cssText = next;
}
}
else if (prev) {
el.removeAttribute('style');
}
// indicates that the `display` of the element is controlled by `v-show`,
// so we always keep the current `display` value regardless of the `style`
// value, thus handing over control to `v-show`.
if ('_vod' in el) {
style.display = currentDisplay;
}
}
}
const importantRE = /\s*!important$/;
function setStyle(style, name, val) {
if (shared.isArray(val)) {
val.forEach(v => setStyle(style, name, v));
}
else {
if (val == null)
val = '';
if (name.startsWith('--')) {
// custom property definition
style.setProperty(name, val);
}
else {
const prefixed = autoPrefix(style, name);
if (importantRE.test(val)) {
// !important
style.setProperty(shared.hyphenate(prefixed), val.replace(importantRE, ''), 'important');
}
else {
style[prefixed] = val;
}
}
}
}
const prefixes = ['Webkit', 'Moz', 'ms'];
const prefixCache = {};
function autoPrefix(style, rawName) {
const cached = prefixCache[rawName];
if (cached) {
return cached;
}
let name = runtimeCore.camelize(rawName);
if (name !== 'filter' && name in style) {
return (prefixCache[rawName] = name);
}
name = shared.capitalize(name);
for (let i = 0; i < prefixes.length; i++) {
const prefixed = prefixes[i] + name;
if (prefixed in style) {
return (prefixCache[rawName] = prefixed);
}
}
return rawName;
}
const xlinkNS = 'http://www.w3.org/1999/xlink';
function patchAttr(el, key, value, isSVG, instance) {
if (isSVG && key.startsWith('xlink:')) {
if (value == null) {
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
}
else {
el.setAttributeNS(xlinkNS, key, value);
}
}
else {
// note we are only checking boolean attributes that don't have a
// corresponding dom prop of the same name here.
const isBoolean = shared.isSpecialBooleanAttr(key);
if (value == null || (isBoolean && !shared.includeBooleanAttr(value))) {
el.removeAttribute(key);
}
else {
el.setAttribute(key, isBoolean ? '' : value);
}
}
}
// __UNSAFE__
// functions. The user is responsible for using them with only trusted content.
function patchDOMProp(el, key, value,
// the following args are passed only due to potential innerHTML/textContent
// overriding existing VNodes, in which case the old tree must be properly
// unmounted.
prevChildren, parentComponent, parentSuspense, unmountChildren) {
if (key === 'innerHTML' || key === 'textContent') {
if (prevChildren) {
unmountChildren(prevChildren, parentComponent, parentSuspense);
}
el[key] = value == null ? '' : value;
return;
}
if (key === 'value' &&
el.tagName !== 'PROGRESS' &&
// custom elements may use _value internally
!el.tagName.includes('-')) {
// store value as _value as well since
// non-string values will be stringified.
el._value = value;
const newValue = value == null ? '' : value;
if (el.value !== newValue ||
// #4956: always set for OPTION elements because its value falls back to
// textContent if no value attribute is present. And setting .value for
// OPTION has no side effect
el.tagName === 'OPTION') {
el.value = newValue;
}
if (value == null) {
el.removeAttribute(key);
}
return;
}
let needRemove = false;
if (value === '' || value == null) {
const type = typeof el[key];
if (type === 'boolean') {
// e.g.