runtime-dom.cjs.js 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var runtimeCore = require('@vue/runtime-core');
  4. var shared = require('@vue/shared');
  5. const svgNS = 'http://www.w3.org/2000/svg';
  6. const doc = (typeof document !== 'undefined' ? document : null);
  7. let tempContainer;
  8. let tempSVGContainer;
  9. const nodeOps = {
  10. insert: (child, parent, anchor) => {
  11. parent.insertBefore(child, anchor || null);
  12. },
  13. remove: child => {
  14. const parent = child.parentNode;
  15. if (parent) {
  16. parent.removeChild(child);
  17. }
  18. },
  19. createElement: (tag, isSVG, is) => isSVG
  20. ? doc.createElementNS(svgNS, tag)
  21. : doc.createElement(tag, is ? { is } : undefined),
  22. createText: text => doc.createTextNode(text),
  23. createComment: text => doc.createComment(text),
  24. setText: (node, text) => {
  25. node.nodeValue = text;
  26. },
  27. setElementText: (el, text) => {
  28. el.textContent = text;
  29. },
  30. parentNode: node => node.parentNode,
  31. nextSibling: node => node.nextSibling,
  32. querySelector: selector => doc.querySelector(selector),
  33. setScopeId(el, id) {
  34. el.setAttribute(id, '');
  35. },
  36. cloneNode(el) {
  37. return el.cloneNode(true);
  38. },
  39. // __UNSAFE__
  40. // Reason: innerHTML.
  41. // Static content here can only come from compiled templates.
  42. // As long as the user only uses trusted templates, this is safe.
  43. insertStaticContent(content, parent, anchor, isSVG) {
  44. const temp = isSVG
  45. ? tempSVGContainer ||
  46. (tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
  47. : tempContainer || (tempContainer = doc.createElement('div'));
  48. temp.innerHTML = content;
  49. const first = temp.firstChild;
  50. let node = first;
  51. let last = node;
  52. while (node) {
  53. last = node;
  54. nodeOps.insert(node, parent, anchor);
  55. node = temp.firstChild;
  56. }
  57. return [first, last];
  58. }
  59. };
  60. // compiler should normalize class + :class bindings on the same element
  61. // into a single binding ['staticClass', dynamic]
  62. function patchClass(el, value, isSVG) {
  63. if (value == null) {
  64. value = '';
  65. }
  66. if (isSVG) {
  67. el.setAttribute('class', value);
  68. }
  69. else {
  70. // directly setting className should be faster than setAttribute in theory
  71. // if this is an element during a transition, take the temporary transition
  72. // classes into account.
  73. const transitionClasses = el._vtc;
  74. if (transitionClasses) {
  75. value = (value
  76. ? [value, ...transitionClasses]
  77. : [...transitionClasses]).join(' ');
  78. }
  79. el.className = value;
  80. }
  81. }
  82. function patchStyle(el, prev, next) {
  83. const style = el.style;
  84. if (!next) {
  85. el.removeAttribute('style');
  86. }
  87. else if (shared.isString(next)) {
  88. if (prev !== next) {
  89. style.cssText = next;
  90. }
  91. }
  92. else {
  93. for (const key in next) {
  94. setStyle(style, key, next[key]);
  95. }
  96. if (prev && !shared.isString(prev)) {
  97. for (const key in prev) {
  98. if (next[key] == null) {
  99. setStyle(style, key, '');
  100. }
  101. }
  102. }
  103. }
  104. }
  105. const importantRE = /\s*!important$/;
  106. function setStyle(style, name, val) {
  107. if (shared.isArray(val)) {
  108. val.forEach(v => setStyle(style, name, v));
  109. }
  110. else {
  111. if (name.startsWith('--')) {
  112. // custom property definition
  113. style.setProperty(name, val);
  114. }
  115. else {
  116. const prefixed = autoPrefix(style, name);
  117. if (importantRE.test(val)) {
  118. // !important
  119. style.setProperty(shared.hyphenate(prefixed), val.replace(importantRE, ''), 'important');
  120. }
  121. else {
  122. style[prefixed] = val;
  123. }
  124. }
  125. }
  126. }
  127. const prefixes = ['Webkit', 'Moz', 'ms'];
  128. const prefixCache = {};
  129. function autoPrefix(style, rawName) {
  130. const cached = prefixCache[rawName];
  131. if (cached) {
  132. return cached;
  133. }
  134. let name = runtimeCore.camelize(rawName);
  135. if (name !== 'filter' && name in style) {
  136. return (prefixCache[rawName] = name);
  137. }
  138. name = shared.capitalize(name);
  139. for (let i = 0; i < prefixes.length; i++) {
  140. const prefixed = prefixes[i] + name;
  141. if (prefixed in style) {
  142. return (prefixCache[rawName] = prefixed);
  143. }
  144. }
  145. return rawName;
  146. }
  147. const xlinkNS = 'http://www.w3.org/1999/xlink';
  148. function patchAttr(el, key, value, isSVG) {
  149. if (isSVG && key.startsWith('xlink:')) {
  150. if (value == null) {
  151. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  152. }
  153. else {
  154. el.setAttributeNS(xlinkNS, key, value);
  155. }
  156. }
  157. else {
  158. // note we are only checking boolean attributes that don't have a
  159. // corresponding dom prop of the same name here.
  160. const isBoolean = shared.isSpecialBooleanAttr(key);
  161. if (value == null || (isBoolean && value === false)) {
  162. el.removeAttribute(key);
  163. }
  164. else {
  165. el.setAttribute(key, isBoolean ? '' : value);
  166. }
  167. }
  168. }
  169. // __UNSAFE__
  170. // functions. The user is responsible for using them with only trusted content.
  171. function patchDOMProp(el, key, value,
  172. // the following args are passed only due to potential innerHTML/textContent
  173. // overriding existing VNodes, in which case the old tree must be properly
  174. // unmounted.
  175. prevChildren, parentComponent, parentSuspense, unmountChildren) {
  176. if (key === 'innerHTML' || key === 'textContent') {
  177. if (prevChildren) {
  178. unmountChildren(prevChildren, parentComponent, parentSuspense);
  179. }
  180. el[key] = value == null ? '' : value;
  181. return;
  182. }
  183. if (key === 'value' && el.tagName !== 'PROGRESS') {
  184. // store value as _value as well since
  185. // non-string values will be stringified.
  186. el._value = value;
  187. const newValue = value == null ? '' : value;
  188. if (el.value !== newValue) {
  189. el.value = newValue;
  190. }
  191. return;
  192. }
  193. if (value === '' && typeof el[key] === 'boolean') {
  194. // e.g. <select multiple> compiles to { multiple: '' }
  195. el[key] = true;
  196. }
  197. else if (value == null && typeof el[key] === 'string') {
  198. // e.g. <div :id="null">
  199. el[key] = '';
  200. el.removeAttribute(key);
  201. }
  202. else {
  203. // some properties perform value validation and throw
  204. try {
  205. el[key] = value;
  206. }
  207. catch (e) {
  208. {
  209. runtimeCore.warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
  210. `value ${value} is invalid.`, e);
  211. }
  212. }
  213. }
  214. }
  215. // Async edge case fix requires storing an event listener's attach timestamp.
  216. let _getNow = Date.now;
  217. // Determine what event timestamp the browser is using. Annoyingly, the
  218. // timestamp can either be hi-res (relative to page load) or low-res
  219. // (relative to UNIX epoch), so in order to compare time we have to use the
  220. // same timestamp type when saving the flush timestamp.
  221. if (typeof document !== 'undefined' &&
  222. _getNow() > document.createEvent('Event').timeStamp) {
  223. // if the low-res timestamp which is bigger than the event timestamp
  224. // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
  225. // and we need to use the hi-res version for event listeners as well.
  226. _getNow = () => performance.now();
  227. }
  228. // To avoid the overhead of repeatedly calling performance.now(), we cache
  229. // and use the same timestamp for all event listeners attached in the same tick.
  230. let cachedNow = 0;
  231. const p = Promise.resolve();
  232. const reset = () => {
  233. cachedNow = 0;
  234. };
  235. const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
  236. function addEventListener(el, event, handler, options) {
  237. el.addEventListener(event, handler, options);
  238. }
  239. function removeEventListener(el, event, handler, options) {
  240. el.removeEventListener(event, handler, options);
  241. }
  242. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  243. // vei = vue event invokers
  244. const invokers = el._vei || (el._vei = {});
  245. const existingInvoker = invokers[rawName];
  246. if (nextValue && existingInvoker) {
  247. // patch
  248. existingInvoker.value = nextValue;
  249. }
  250. else {
  251. const [name, options] = parseName(rawName);
  252. if (nextValue) {
  253. // add
  254. const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
  255. addEventListener(el, name, invoker, options);
  256. }
  257. else if (existingInvoker) {
  258. // remove
  259. removeEventListener(el, name, existingInvoker, options);
  260. invokers[rawName] = undefined;
  261. }
  262. }
  263. }
  264. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  265. function parseName(name) {
  266. let options;
  267. if (optionsModifierRE.test(name)) {
  268. options = {};
  269. let m;
  270. while ((m = name.match(optionsModifierRE))) {
  271. name = name.slice(0, name.length - m[0].length);
  272. options[m[0].toLowerCase()] = true;
  273. }
  274. }
  275. return [name.slice(2).toLowerCase(), options];
  276. }
  277. function createInvoker(initialValue, instance) {
  278. const invoker = (e) => {
  279. // async edge case #6566: inner click event triggers patch, event handler
  280. // attached to outer element during patch, and triggered again. This
  281. // happens because browsers fire microtask ticks between event propagation.
  282. // the solution is simple: we save the timestamp when a handler is attached,
  283. // and the handler would only fire if the event passed to it was fired
  284. // AFTER it was attached.
  285. const timeStamp = e.timeStamp || _getNow();
  286. if (timeStamp >= invoker.attached - 1) {
  287. runtimeCore.callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* NATIVE_EVENT_HANDLER */, [e]);
  288. }
  289. };
  290. invoker.value = initialValue;
  291. invoker.attached = getNow();
  292. return invoker;
  293. }
  294. function patchStopImmediatePropagation(e, value) {
  295. if (shared.isArray(value)) {
  296. const originalStop = e.stopImmediatePropagation;
  297. e.stopImmediatePropagation = () => {
  298. originalStop.call(e);
  299. e._stopped = true;
  300. };
  301. return value.map(fn => (e) => !e._stopped && fn(e));
  302. }
  303. else {
  304. return value;
  305. }
  306. }
  307. const nativeOnRE = /^on[a-z]/;
  308. const forcePatchProp = (_, key) => key === 'value';
  309. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  310. switch (key) {
  311. // special
  312. case 'class':
  313. patchClass(el, nextValue, isSVG);
  314. break;
  315. case 'style':
  316. patchStyle(el, prevValue, nextValue);
  317. break;
  318. default:
  319. if (shared.isOn(key)) {
  320. // ignore v-model listeners
  321. if (!shared.isModelListener(key)) {
  322. patchEvent(el, key, prevValue, nextValue, parentComponent);
  323. }
  324. }
  325. else if (shouldSetAsProp(el, key, nextValue, isSVG)) {
  326. patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
  327. }
  328. else {
  329. // special case for <input v-model type="checkbox"> with
  330. // :true-value & :false-value
  331. // store value as dom properties since non-string values will be
  332. // stringified.
  333. if (key === 'true-value') {
  334. el._trueValue = nextValue;
  335. }
  336. else if (key === 'false-value') {
  337. el._falseValue = nextValue;
  338. }
  339. patchAttr(el, key, nextValue, isSVG);
  340. }
  341. break;
  342. }
  343. };
  344. function shouldSetAsProp(el, key, value, isSVG) {
  345. if (isSVG) {
  346. // most keys must be set as attribute on svg elements to work
  347. // ...except innerHTML
  348. if (key === 'innerHTML') {
  349. return true;
  350. }
  351. // or native onclick with function values
  352. if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) {
  353. return true;
  354. }
  355. return false;
  356. }
  357. // spellcheck and draggable are numerated attrs, however their
  358. // corresponding DOM properties are actually booleans - this leads to
  359. // setting it with a string "false" value leading it to be coerced to
  360. // `true`, so we need to always treat them as attributes.
  361. // Note that `contentEditable` doesn't have this problem: its DOM
  362. // property is also enumerated string values.
  363. if (key === 'spellcheck' || key === 'draggable') {
  364. return false;
  365. }
  366. // #1787 form as an attribute must be a string, while it accepts an Element as
  367. // a prop
  368. if (key === 'form' && typeof value === 'string') {
  369. return false;
  370. }
  371. // #1526 <input list> must be set as attribute
  372. if (key === 'list' && el.tagName === 'INPUT') {
  373. return false;
  374. }
  375. // native onclick with string value, must be set as attribute
  376. if (nativeOnRE.test(key) && shared.isString(value)) {
  377. return false;
  378. }
  379. return key in el;
  380. }
  381. function useCssModule(name = '$style') {
  382. /* istanbul ignore else */
  383. {
  384. const instance = runtimeCore.getCurrentInstance();
  385. if (!instance) {
  386. runtimeCore.warn(`useCssModule must be called inside setup()`);
  387. return shared.EMPTY_OBJ;
  388. }
  389. const modules = instance.type.__cssModules;
  390. if (!modules) {
  391. runtimeCore.warn(`Current instance does not have CSS modules injected.`);
  392. return shared.EMPTY_OBJ;
  393. }
  394. const mod = modules[name];
  395. if (!mod) {
  396. runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
  397. return shared.EMPTY_OBJ;
  398. }
  399. return mod;
  400. }
  401. }
  402. function useCssVars(getter, scoped = false) {
  403. const instance = runtimeCore.getCurrentInstance();
  404. /* istanbul ignore next */
  405. if (!instance) {
  406. runtimeCore.warn(`useCssVars is called without current active component instance.`);
  407. return;
  408. }
  409. const prefix = scoped && instance.type.__scopeId
  410. ? `${instance.type.__scopeId.replace(/^data-v-/, '')}-`
  411. : ``;
  412. const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy), prefix);
  413. runtimeCore.onMounted(() => runtimeCore.watchEffect(setVars));
  414. runtimeCore.onUpdated(setVars);
  415. }
  416. function setVarsOnVNode(vnode, vars, prefix) {
  417. if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
  418. const suspense = vnode.suspense;
  419. vnode = suspense.activeBranch;
  420. if (suspense.pendingBranch && !suspense.isHydrating) {
  421. suspense.effects.push(() => {
  422. setVarsOnVNode(suspense.activeBranch, vars, prefix);
  423. });
  424. }
  425. }
  426. // drill down HOCs until it's a non-component vnode
  427. while (vnode.component) {
  428. vnode = vnode.component.subTree;
  429. }
  430. if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
  431. const style = vnode.el.style;
  432. for (const key in vars) {
  433. style.setProperty(`--${prefix}${key}`, runtimeCore.unref(vars[key]));
  434. }
  435. }
  436. else if (vnode.type === runtimeCore.Fragment) {
  437. vnode.children.forEach(c => setVarsOnVNode(c, vars, prefix));
  438. }
  439. }
  440. const TRANSITION = 'transition';
  441. const ANIMATION = 'animation';
  442. // DOM Transition is a higher-order-component based on the platform-agnostic
  443. // base Transition component, with DOM-specific logic.
  444. const Transition = (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots);
  445. Transition.displayName = 'Transition';
  446. const DOMTransitionPropsValidators = {
  447. name: String,
  448. type: String,
  449. css: {
  450. type: Boolean,
  451. default: true
  452. },
  453. duration: [String, Number, Object],
  454. enterFromClass: String,
  455. enterActiveClass: String,
  456. enterToClass: String,
  457. appearFromClass: String,
  458. appearActiveClass: String,
  459. appearToClass: String,
  460. leaveFromClass: String,
  461. leaveActiveClass: String,
  462. leaveToClass: String
  463. };
  464. const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ shared.extend({}, runtimeCore.BaseTransition.props, DOMTransitionPropsValidators));
  465. function resolveTransitionProps(rawProps) {
  466. let { name = 'v', type, css = true, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
  467. const baseProps = {};
  468. for (const key in rawProps) {
  469. if (!(key in DOMTransitionPropsValidators)) {
  470. baseProps[key] = rawProps[key];
  471. }
  472. }
  473. if (!css) {
  474. return baseProps;
  475. }
  476. const durations = normalizeDuration(duration);
  477. const enterDuration = durations && durations[0];
  478. const leaveDuration = durations && durations[1];
  479. const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
  480. const finishEnter = (el, isAppear, done) => {
  481. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  482. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  483. done && done();
  484. };
  485. const finishLeave = (el, done) => {
  486. removeTransitionClass(el, leaveToClass);
  487. removeTransitionClass(el, leaveActiveClass);
  488. done && done();
  489. };
  490. const makeEnterHook = (isAppear) => {
  491. return (el, done) => {
  492. const hook = isAppear ? onAppear : onEnter;
  493. const resolve = () => finishEnter(el, isAppear, done);
  494. hook && hook(el, resolve);
  495. nextFrame(() => {
  496. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  497. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  498. if (!(hook && hook.length > 1)) {
  499. if (enterDuration) {
  500. setTimeout(resolve, enterDuration);
  501. }
  502. else {
  503. whenTransitionEnds(el, type, resolve);
  504. }
  505. }
  506. });
  507. };
  508. };
  509. return shared.extend(baseProps, {
  510. onBeforeEnter(el) {
  511. onBeforeEnter && onBeforeEnter(el);
  512. addTransitionClass(el, enterActiveClass);
  513. addTransitionClass(el, enterFromClass);
  514. },
  515. onBeforeAppear(el) {
  516. onBeforeAppear && onBeforeAppear(el);
  517. addTransitionClass(el, appearActiveClass);
  518. addTransitionClass(el, appearFromClass);
  519. },
  520. onEnter: makeEnterHook(false),
  521. onAppear: makeEnterHook(true),
  522. onLeave(el, done) {
  523. const resolve = () => finishLeave(el, done);
  524. addTransitionClass(el, leaveActiveClass);
  525. addTransitionClass(el, leaveFromClass);
  526. nextFrame(() => {
  527. removeTransitionClass(el, leaveFromClass);
  528. addTransitionClass(el, leaveToClass);
  529. if (!(onLeave && onLeave.length > 1)) {
  530. if (leaveDuration) {
  531. setTimeout(resolve, leaveDuration);
  532. }
  533. else {
  534. whenTransitionEnds(el, type, resolve);
  535. }
  536. }
  537. });
  538. onLeave && onLeave(el, resolve);
  539. },
  540. onEnterCancelled(el) {
  541. finishEnter(el, false);
  542. onEnterCancelled && onEnterCancelled(el);
  543. },
  544. onAppearCancelled(el) {
  545. finishEnter(el, true);
  546. onAppearCancelled && onAppearCancelled(el);
  547. },
  548. onLeaveCancelled(el) {
  549. finishLeave(el);
  550. onLeaveCancelled && onLeaveCancelled(el);
  551. }
  552. });
  553. }
  554. function normalizeDuration(duration) {
  555. if (duration == null) {
  556. return null;
  557. }
  558. else if (shared.isObject(duration)) {
  559. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  560. }
  561. else {
  562. const n = NumberOf(duration);
  563. return [n, n];
  564. }
  565. }
  566. function NumberOf(val) {
  567. const res = shared.toNumber(val);
  568. validateDuration(res);
  569. return res;
  570. }
  571. function validateDuration(val) {
  572. if (typeof val !== 'number') {
  573. runtimeCore.warn(`<transition> explicit duration is not a valid number - ` +
  574. `got ${JSON.stringify(val)}.`);
  575. }
  576. else if (isNaN(val)) {
  577. runtimeCore.warn(`<transition> explicit duration is NaN - ` +
  578. 'the duration expression might be incorrect.');
  579. }
  580. }
  581. function addTransitionClass(el, cls) {
  582. cls.split(/\s+/).forEach(c => c && el.classList.add(c));
  583. (el._vtc ||
  584. (el._vtc = new Set())).add(cls);
  585. }
  586. function removeTransitionClass(el, cls) {
  587. cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
  588. const { _vtc } = el;
  589. if (_vtc) {
  590. _vtc.delete(cls);
  591. if (!_vtc.size) {
  592. el._vtc = undefined;
  593. }
  594. }
  595. }
  596. function nextFrame(cb) {
  597. requestAnimationFrame(() => {
  598. requestAnimationFrame(cb);
  599. });
  600. }
  601. function whenTransitionEnds(el, expectedType, cb) {
  602. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  603. if (!type) {
  604. return cb();
  605. }
  606. const endEvent = type + 'end';
  607. let ended = 0;
  608. const end = () => {
  609. el.removeEventListener(endEvent, onEnd);
  610. cb();
  611. };
  612. const onEnd = (e) => {
  613. if (e.target === el) {
  614. if (++ended >= propCount) {
  615. end();
  616. }
  617. }
  618. };
  619. setTimeout(() => {
  620. if (ended < propCount) {
  621. end();
  622. }
  623. }, timeout + 1);
  624. el.addEventListener(endEvent, onEnd);
  625. }
  626. function getTransitionInfo(el, expectedType) {
  627. const styles = window.getComputedStyle(el);
  628. // JSDOM may return undefined for transition properties
  629. const getStyleProperties = (key) => (styles[key] || '').split(', ');
  630. const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
  631. const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
  632. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  633. const animationDelays = getStyleProperties(ANIMATION + 'Delay');
  634. const animationDurations = getStyleProperties(ANIMATION + 'Duration');
  635. const animationTimeout = getTimeout(animationDelays, animationDurations);
  636. let type = null;
  637. let timeout = 0;
  638. let propCount = 0;
  639. /* istanbul ignore if */
  640. if (expectedType === TRANSITION) {
  641. if (transitionTimeout > 0) {
  642. type = TRANSITION;
  643. timeout = transitionTimeout;
  644. propCount = transitionDurations.length;
  645. }
  646. }
  647. else if (expectedType === ANIMATION) {
  648. if (animationTimeout > 0) {
  649. type = ANIMATION;
  650. timeout = animationTimeout;
  651. propCount = animationDurations.length;
  652. }
  653. }
  654. else {
  655. timeout = Math.max(transitionTimeout, animationTimeout);
  656. type =
  657. timeout > 0
  658. ? transitionTimeout > animationTimeout
  659. ? TRANSITION
  660. : ANIMATION
  661. : null;
  662. propCount = type
  663. ? type === TRANSITION
  664. ? transitionDurations.length
  665. : animationDurations.length
  666. : 0;
  667. }
  668. const hasTransform = type === TRANSITION &&
  669. /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
  670. return {
  671. type,
  672. timeout,
  673. propCount,
  674. hasTransform
  675. };
  676. }
  677. function getTimeout(delays, durations) {
  678. while (delays.length < durations.length) {
  679. delays = delays.concat(delays);
  680. }
  681. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  682. }
  683. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
  684. // numbers in a locale-dependent way, using a comma instead of a dot.
  685. // If comma is not replaced with a dot, the input will be rounded down
  686. // (i.e. acting as a floor function) causing unexpected behaviors
  687. function toMs(s) {
  688. return Number(s.slice(0, -1).replace(',', '.')) * 1000;
  689. }
  690. function toRaw(observed) {
  691. return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
  692. }
  693. const positionMap = new WeakMap();
  694. const newPositionMap = new WeakMap();
  695. const TransitionGroupImpl = {
  696. name: 'TransitionGroup',
  697. props: /*#__PURE__*/ shared.extend({}, TransitionPropsValidators, {
  698. tag: String,
  699. moveClass: String
  700. }),
  701. setup(props, { slots }) {
  702. const instance = runtimeCore.getCurrentInstance();
  703. const state = runtimeCore.useTransitionState();
  704. let prevChildren;
  705. let children;
  706. runtimeCore.onUpdated(() => {
  707. // children is guaranteed to exist after initial render
  708. if (!prevChildren.length) {
  709. return;
  710. }
  711. const moveClass = props.moveClass || `${props.name || 'v'}-move`;
  712. if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
  713. return;
  714. }
  715. // we divide the work into three loops to avoid mixing DOM reads and writes
  716. // in each iteration - which helps prevent layout thrashing.
  717. prevChildren.forEach(callPendingCbs);
  718. prevChildren.forEach(recordPosition);
  719. const movedChildren = prevChildren.filter(applyTranslation);
  720. // force reflow to put everything in position
  721. forceReflow();
  722. movedChildren.forEach(c => {
  723. const el = c.el;
  724. const style = el.style;
  725. addTransitionClass(el, moveClass);
  726. style.transform = style.webkitTransform = style.transitionDuration = '';
  727. const cb = (el._moveCb = (e) => {
  728. if (e && e.target !== el) {
  729. return;
  730. }
  731. if (!e || /transform$/.test(e.propertyName)) {
  732. el.removeEventListener('transitionend', cb);
  733. el._moveCb = null;
  734. removeTransitionClass(el, moveClass);
  735. }
  736. });
  737. el.addEventListener('transitionend', cb);
  738. });
  739. });
  740. return () => {
  741. const rawProps = toRaw(props);
  742. const cssTransitionProps = resolveTransitionProps(rawProps);
  743. const tag = rawProps.tag || runtimeCore.Fragment;
  744. prevChildren = children;
  745. children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
  746. for (let i = 0; i < children.length; i++) {
  747. const child = children[i];
  748. if (child.key != null) {
  749. runtimeCore.setTransitionHooks(child, runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance));
  750. }
  751. else {
  752. runtimeCore.warn(`<TransitionGroup> children must be keyed.`);
  753. }
  754. }
  755. if (prevChildren) {
  756. for (let i = 0; i < prevChildren.length; i++) {
  757. const child = prevChildren[i];
  758. runtimeCore.setTransitionHooks(child, runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance));
  759. positionMap.set(child, child.el.getBoundingClientRect());
  760. }
  761. }
  762. return runtimeCore.createVNode(tag, null, children);
  763. };
  764. }
  765. };
  766. const TransitionGroup = TransitionGroupImpl;
  767. function callPendingCbs(c) {
  768. const el = c.el;
  769. if (el._moveCb) {
  770. el._moveCb();
  771. }
  772. if (el._enterCb) {
  773. el._enterCb();
  774. }
  775. }
  776. function recordPosition(c) {
  777. newPositionMap.set(c, c.el.getBoundingClientRect());
  778. }
  779. function applyTranslation(c) {
  780. const oldPos = positionMap.get(c);
  781. const newPos = newPositionMap.get(c);
  782. const dx = oldPos.left - newPos.left;
  783. const dy = oldPos.top - newPos.top;
  784. if (dx || dy) {
  785. const s = c.el.style;
  786. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  787. s.transitionDuration = '0s';
  788. return c;
  789. }
  790. }
  791. // this is put in a dedicated function to avoid the line from being treeshaken
  792. function forceReflow() {
  793. return document.body.offsetHeight;
  794. }
  795. function hasCSSTransform(el, root, moveClass) {
  796. // Detect whether an element with the move class applied has
  797. // CSS transitions. Since the element may be inside an entering
  798. // transition at this very moment, we make a clone of it and remove
  799. // all other transition classes applied to ensure only the move class
  800. // is applied.
  801. const clone = el.cloneNode();
  802. if (el._vtc) {
  803. el._vtc.forEach(cls => {
  804. cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
  805. });
  806. }
  807. moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
  808. clone.style.display = 'none';
  809. const container = (root.nodeType === 1
  810. ? root
  811. : root.parentNode);
  812. container.appendChild(clone);
  813. const { hasTransform } = getTransitionInfo(clone);
  814. container.removeChild(clone);
  815. return hasTransform;
  816. }
  817. const getModelAssigner = (vnode) => {
  818. const fn = vnode.props['onUpdate:modelValue'];
  819. return shared.isArray(fn) ? value => shared.invokeArrayFns(fn, value) : fn;
  820. };
  821. function onCompositionStart(e) {
  822. e.target.composing = true;
  823. }
  824. function onCompositionEnd(e) {
  825. const target = e.target;
  826. if (target.composing) {
  827. target.composing = false;
  828. trigger(target, 'input');
  829. }
  830. }
  831. function trigger(el, type) {
  832. const e = document.createEvent('HTMLEvents');
  833. e.initEvent(type, true, true);
  834. el.dispatchEvent(e);
  835. }
  836. // We are exporting the v-model runtime directly as vnode hooks so that it can
  837. // be tree-shaken in case v-model is never used.
  838. const vModelText = {
  839. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  840. el._assign = getModelAssigner(vnode);
  841. const castToNumber = number || el.type === 'number';
  842. addEventListener(el, lazy ? 'change' : 'input', e => {
  843. if (e.target.composing)
  844. return;
  845. let domValue = el.value;
  846. if (trim) {
  847. domValue = domValue.trim();
  848. }
  849. else if (castToNumber) {
  850. domValue = shared.toNumber(domValue);
  851. }
  852. el._assign(domValue);
  853. });
  854. if (trim) {
  855. addEventListener(el, 'change', () => {
  856. el.value = el.value.trim();
  857. });
  858. }
  859. if (!lazy) {
  860. addEventListener(el, 'compositionstart', onCompositionStart);
  861. addEventListener(el, 'compositionend', onCompositionEnd);
  862. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  863. // switching focus before confirming composition choice
  864. // this also fixes the issue where some browsers e.g. iOS Chrome
  865. // fires "change" instead of "input" on autocomplete.
  866. addEventListener(el, 'change', onCompositionEnd);
  867. }
  868. },
  869. // set value on mounted so it's after min/max for type="range"
  870. mounted(el, { value }) {
  871. el.value = value == null ? '' : value;
  872. },
  873. beforeUpdate(el, { value, modifiers: { trim, number } }, vnode) {
  874. el._assign = getModelAssigner(vnode);
  875. // avoid clearing unresolved text. #2302
  876. if (el.composing)
  877. return;
  878. if (document.activeElement === el) {
  879. if (trim && el.value.trim() === value) {
  880. return;
  881. }
  882. if ((number || el.type === 'number') && shared.toNumber(el.value) === value) {
  883. return;
  884. }
  885. }
  886. const newValue = value == null ? '' : value;
  887. if (el.value !== newValue) {
  888. el.value = newValue;
  889. }
  890. }
  891. };
  892. const vModelCheckbox = {
  893. created(el, binding, vnode) {
  894. setChecked(el, binding, vnode);
  895. el._assign = getModelAssigner(vnode);
  896. addEventListener(el, 'change', () => {
  897. const modelValue = el._modelValue;
  898. const elementValue = getValue(el);
  899. const checked = el.checked;
  900. const assign = el._assign;
  901. if (shared.isArray(modelValue)) {
  902. const index = shared.looseIndexOf(modelValue, elementValue);
  903. const found = index !== -1;
  904. if (checked && !found) {
  905. assign(modelValue.concat(elementValue));
  906. }
  907. else if (!checked && found) {
  908. const filtered = [...modelValue];
  909. filtered.splice(index, 1);
  910. assign(filtered);
  911. }
  912. }
  913. else if (shared.isSet(modelValue)) {
  914. if (checked) {
  915. modelValue.add(elementValue);
  916. }
  917. else {
  918. modelValue.delete(elementValue);
  919. }
  920. }
  921. else {
  922. assign(getCheckboxValue(el, checked));
  923. }
  924. });
  925. },
  926. beforeUpdate(el, binding, vnode) {
  927. el._assign = getModelAssigner(vnode);
  928. setChecked(el, binding, vnode);
  929. }
  930. };
  931. function setChecked(el, { value, oldValue }, vnode) {
  932. el._modelValue = value;
  933. if (shared.isArray(value)) {
  934. el.checked = shared.looseIndexOf(value, vnode.props.value) > -1;
  935. }
  936. else if (shared.isSet(value)) {
  937. el.checked = value.has(vnode.props.value);
  938. }
  939. else if (value !== oldValue) {
  940. el.checked = shared.looseEqual(value, getCheckboxValue(el, true));
  941. }
  942. }
  943. const vModelRadio = {
  944. created(el, { value }, vnode) {
  945. el.checked = shared.looseEqual(value, vnode.props.value);
  946. el._assign = getModelAssigner(vnode);
  947. addEventListener(el, 'change', () => {
  948. el._assign(getValue(el));
  949. });
  950. },
  951. beforeUpdate(el, { value, oldValue }, vnode) {
  952. el._assign = getModelAssigner(vnode);
  953. if (value !== oldValue) {
  954. el.checked = shared.looseEqual(value, vnode.props.value);
  955. }
  956. }
  957. };
  958. const vModelSelect = {
  959. created(el, { modifiers: { number } }, vnode) {
  960. addEventListener(el, 'change', () => {
  961. const selectedVal = Array.prototype.filter
  962. .call(el.options, (o) => o.selected)
  963. .map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
  964. el._assign(el.multiple ? selectedVal : selectedVal[0]);
  965. });
  966. el._assign = getModelAssigner(vnode);
  967. },
  968. // set value in mounted & updated because <select> relies on its children
  969. // <option>s.
  970. mounted(el, { value }) {
  971. setSelected(el, value);
  972. },
  973. beforeUpdate(el, _binding, vnode) {
  974. el._assign = getModelAssigner(vnode);
  975. },
  976. updated(el, { value }) {
  977. setSelected(el, value);
  978. }
  979. };
  980. function setSelected(el, value) {
  981. const isMultiple = el.multiple;
  982. if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) {
  983. runtimeCore.warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
  984. `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
  985. return;
  986. }
  987. for (let i = 0, l = el.options.length; i < l; i++) {
  988. const option = el.options[i];
  989. const optionValue = getValue(option);
  990. if (isMultiple) {
  991. if (shared.isArray(value)) {
  992. option.selected = shared.looseIndexOf(value, optionValue) > -1;
  993. }
  994. else {
  995. option.selected = value.has(optionValue);
  996. }
  997. }
  998. else {
  999. if (shared.looseEqual(getValue(option), value)) {
  1000. el.selectedIndex = i;
  1001. return;
  1002. }
  1003. }
  1004. }
  1005. if (!isMultiple) {
  1006. el.selectedIndex = -1;
  1007. }
  1008. }
  1009. // retrieve raw value set via :value bindings
  1010. function getValue(el) {
  1011. return '_value' in el ? el._value : el.value;
  1012. }
  1013. // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
  1014. function getCheckboxValue(el, checked) {
  1015. const key = checked ? '_trueValue' : '_falseValue';
  1016. return key in el ? el[key] : checked;
  1017. }
  1018. const vModelDynamic = {
  1019. created(el, binding, vnode) {
  1020. callModelHook(el, binding, vnode, null, 'created');
  1021. },
  1022. mounted(el, binding, vnode) {
  1023. callModelHook(el, binding, vnode, null, 'mounted');
  1024. },
  1025. beforeUpdate(el, binding, vnode, prevVNode) {
  1026. callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
  1027. },
  1028. updated(el, binding, vnode, prevVNode) {
  1029. callModelHook(el, binding, vnode, prevVNode, 'updated');
  1030. }
  1031. };
  1032. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1033. let modelToUse;
  1034. switch (el.tagName) {
  1035. case 'SELECT':
  1036. modelToUse = vModelSelect;
  1037. break;
  1038. case 'TEXTAREA':
  1039. modelToUse = vModelText;
  1040. break;
  1041. default:
  1042. switch (vnode.props && vnode.props.type) {
  1043. case 'checkbox':
  1044. modelToUse = vModelCheckbox;
  1045. break;
  1046. case 'radio':
  1047. modelToUse = vModelRadio;
  1048. break;
  1049. default:
  1050. modelToUse = vModelText;
  1051. }
  1052. }
  1053. const fn = modelToUse[hook];
  1054. fn && fn(el, binding, vnode, prevVNode);
  1055. }
  1056. // SSR vnode transforms
  1057. {
  1058. vModelText.getSSRProps = ({ value }) => ({ value });
  1059. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1060. if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
  1061. return { checked: true };
  1062. }
  1063. };
  1064. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1065. if (shared.isArray(value)) {
  1066. if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
  1067. return { checked: true };
  1068. }
  1069. }
  1070. else if (shared.isSet(value)) {
  1071. if (vnode.props && value.has(vnode.props.value)) {
  1072. return { checked: true };
  1073. }
  1074. }
  1075. else if (value) {
  1076. return { checked: true };
  1077. }
  1078. };
  1079. }
  1080. const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
  1081. const modifierGuards = {
  1082. stop: e => e.stopPropagation(),
  1083. prevent: e => e.preventDefault(),
  1084. self: e => e.target !== e.currentTarget,
  1085. ctrl: e => !e.ctrlKey,
  1086. shift: e => !e.shiftKey,
  1087. alt: e => !e.altKey,
  1088. meta: e => !e.metaKey,
  1089. left: e => 'button' in e && e.button !== 0,
  1090. middle: e => 'button' in e && e.button !== 1,
  1091. right: e => 'button' in e && e.button !== 2,
  1092. exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
  1093. };
  1094. /**
  1095. * @private
  1096. */
  1097. const withModifiers = (fn, modifiers) => {
  1098. return (event, ...args) => {
  1099. for (let i = 0; i < modifiers.length; i++) {
  1100. const guard = modifierGuards[modifiers[i]];
  1101. if (guard && guard(event, modifiers))
  1102. return;
  1103. }
  1104. return fn(event, ...args);
  1105. };
  1106. };
  1107. // Kept for 2.x compat.
  1108. // Note: IE11 compat for `spacebar` and `del` is removed for now.
  1109. const keyNames = {
  1110. esc: 'escape',
  1111. space: ' ',
  1112. up: 'arrow-up',
  1113. left: 'arrow-left',
  1114. right: 'arrow-right',
  1115. down: 'arrow-down',
  1116. delete: 'backspace'
  1117. };
  1118. /**
  1119. * @private
  1120. */
  1121. const withKeys = (fn, modifiers) => {
  1122. return (event) => {
  1123. if (!('key' in event))
  1124. return;
  1125. const eventKey = shared.hyphenate(event.key);
  1126. if (
  1127. // None of the provided key modifiers match the current event key
  1128. !modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
  1129. return;
  1130. }
  1131. return fn(event);
  1132. };
  1133. };
  1134. const vShow = {
  1135. beforeMount(el, { value }, { transition }) {
  1136. el._vod = el.style.display === 'none' ? '' : el.style.display;
  1137. if (transition && value) {
  1138. transition.beforeEnter(el);
  1139. }
  1140. else {
  1141. setDisplay(el, value);
  1142. }
  1143. },
  1144. mounted(el, { value }, { transition }) {
  1145. if (transition && value) {
  1146. transition.enter(el);
  1147. }
  1148. },
  1149. updated(el, { value, oldValue }, { transition }) {
  1150. if (!value === !oldValue)
  1151. return;
  1152. if (transition) {
  1153. if (value) {
  1154. transition.beforeEnter(el);
  1155. setDisplay(el, true);
  1156. transition.enter(el);
  1157. }
  1158. else {
  1159. transition.leave(el, () => {
  1160. setDisplay(el, false);
  1161. });
  1162. }
  1163. }
  1164. else {
  1165. setDisplay(el, value);
  1166. }
  1167. },
  1168. beforeUnmount(el, { value }) {
  1169. setDisplay(el, value);
  1170. }
  1171. };
  1172. {
  1173. vShow.getSSRProps = ({ value }) => {
  1174. if (!value) {
  1175. return { style: { display: 'none' } };
  1176. }
  1177. };
  1178. }
  1179. function setDisplay(el, value) {
  1180. el.style.display = value ? el._vod : 'none';
  1181. }
  1182. const rendererOptions = shared.extend({ patchProp, forcePatchProp }, nodeOps);
  1183. // lazy create the renderer - this makes core renderer logic tree-shakable
  1184. // in case the user only imports reactivity utilities from Vue.
  1185. let renderer;
  1186. let enabledHydration = false;
  1187. function ensureRenderer() {
  1188. return renderer || (renderer = runtimeCore.createRenderer(rendererOptions));
  1189. }
  1190. function ensureHydrationRenderer() {
  1191. renderer = enabledHydration
  1192. ? renderer
  1193. : runtimeCore.createHydrationRenderer(rendererOptions);
  1194. enabledHydration = true;
  1195. return renderer;
  1196. }
  1197. // use explicit type casts here to avoid import() calls in rolled-up d.ts
  1198. const render = ((...args) => {
  1199. ensureRenderer().render(...args);
  1200. });
  1201. const hydrate = ((...args) => {
  1202. ensureHydrationRenderer().hydrate(...args);
  1203. });
  1204. const createApp = ((...args) => {
  1205. const app = ensureRenderer().createApp(...args);
  1206. {
  1207. injectNativeTagCheck(app);
  1208. }
  1209. const { mount } = app;
  1210. app.mount = (containerOrSelector) => {
  1211. const container = normalizeContainer(containerOrSelector);
  1212. if (!container)
  1213. return;
  1214. const component = app._component;
  1215. if (!shared.isFunction(component) && !component.render && !component.template) {
  1216. component.template = container.innerHTML;
  1217. }
  1218. // clear content before mounting
  1219. container.innerHTML = '';
  1220. const proxy = mount(container);
  1221. container.removeAttribute('v-cloak');
  1222. container.setAttribute('data-v-app', '');
  1223. return proxy;
  1224. };
  1225. return app;
  1226. });
  1227. const createSSRApp = ((...args) => {
  1228. const app = ensureHydrationRenderer().createApp(...args);
  1229. {
  1230. injectNativeTagCheck(app);
  1231. }
  1232. const { mount } = app;
  1233. app.mount = (containerOrSelector) => {
  1234. const container = normalizeContainer(containerOrSelector);
  1235. if (container) {
  1236. return mount(container, true);
  1237. }
  1238. };
  1239. return app;
  1240. });
  1241. function injectNativeTagCheck(app) {
  1242. // Inject `isNativeTag`
  1243. // this is used for component name validation (dev only)
  1244. Object.defineProperty(app.config, 'isNativeTag', {
  1245. value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
  1246. writable: false
  1247. });
  1248. }
  1249. function normalizeContainer(container) {
  1250. if (shared.isString(container)) {
  1251. const res = document.querySelector(container);
  1252. if ( !res) {
  1253. runtimeCore.warn(`Failed to mount app: mount target selector returned null.`);
  1254. }
  1255. return res;
  1256. }
  1257. return container;
  1258. }
  1259. Object.keys(runtimeCore).forEach(function (k) {
  1260. if (k !== 'default') exports[k] = runtimeCore[k];
  1261. });
  1262. exports.Transition = Transition;
  1263. exports.TransitionGroup = TransitionGroup;
  1264. exports.createApp = createApp;
  1265. exports.createSSRApp = createSSRApp;
  1266. exports.hydrate = hydrate;
  1267. exports.render = render;
  1268. exports.useCssModule = useCssModule;
  1269. exports.useCssVars = useCssVars;
  1270. exports.vModelCheckbox = vModelCheckbox;
  1271. exports.vModelDynamic = vModelDynamic;
  1272. exports.vModelRadio = vModelRadio;
  1273. exports.vModelSelect = vModelSelect;
  1274. exports.vModelText = vModelText;
  1275. exports.vShow = vShow;
  1276. exports.withKeys = withKeys;
  1277. exports.withModifiers = withModifiers;