vue.cjs.prod.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var compilerDom = require('@vue/compiler-dom');
  4. var runtimeDom = require('@vue/runtime-dom');
  5. var shared = require('@vue/shared');
  6. function _interopNamespaceDefault(e) {
  7. var n = Object.create(null);
  8. if (e) {
  9. for (var k in e) {
  10. n[k] = e[k];
  11. }
  12. }
  13. n.default = e;
  14. return Object.freeze(n);
  15. }
  16. var runtimeDom__namespace = /*#__PURE__*/_interopNamespaceDefault(runtimeDom);
  17. const compileCache = /* @__PURE__ */ Object.create(null);
  18. function compileToFunction(template, options) {
  19. if (!shared.isString(template)) {
  20. if (template.nodeType) {
  21. template = template.innerHTML;
  22. } else {
  23. return shared.NOOP;
  24. }
  25. }
  26. const key = template;
  27. const cached = compileCache[key];
  28. if (cached) {
  29. return cached;
  30. }
  31. if (template[0] === "#") {
  32. const el = document.querySelector(template);
  33. template = el ? el.innerHTML : ``;
  34. }
  35. const opts = shared.extend(
  36. {
  37. hoistStatic: true,
  38. onError: void 0,
  39. onWarn: shared.NOOP
  40. },
  41. options
  42. );
  43. if (!opts.isCustomElement && typeof customElements !== "undefined") {
  44. opts.isCustomElement = (tag) => !!customElements.get(tag);
  45. }
  46. const { code } = compilerDom.compile(template, opts);
  47. const render = new Function("Vue", code)(runtimeDom__namespace);
  48. render._rc = true;
  49. return compileCache[key] = render;
  50. }
  51. runtimeDom.registerRuntimeCompiler(compileToFunction);
  52. exports.compile = compileToFunction;
  53. Object.keys(runtimeDom).forEach(function (k) {
  54. if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = runtimeDom[k];
  55. });