vue.cjs.prod.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 _interopNamespace(e) {
  7. if (e && e.__esModule) return e;
  8. var n = Object.create(null);
  9. if (e) {
  10. Object.keys(e).forEach(function (k) {
  11. n[k] = e[k];
  12. });
  13. }
  14. n['default'] = e;
  15. return Object.freeze(n);
  16. }
  17. var runtimeDom__namespace = /*#__PURE__*/_interopNamespace(runtimeDom);
  18. // This entry is the "full-build" that includes both the runtime
  19. const compileCache = Object.create(null);
  20. function compileToFunction(template, options) {
  21. if (!shared.isString(template)) {
  22. if (template.nodeType) {
  23. template = template.innerHTML;
  24. }
  25. else {
  26. return shared.NOOP;
  27. }
  28. }
  29. const key = template;
  30. const cached = compileCache[key];
  31. if (cached) {
  32. return cached;
  33. }
  34. if (template[0] === '#') {
  35. const el = document.querySelector(template);
  36. // __UNSAFE__
  37. // Reason: potential execution of JS expressions in in-DOM template.
  38. // The user must make sure the in-DOM template is trusted. If it's rendered
  39. // by the server, the template should not contain any user data.
  40. template = el ? el.innerHTML : ``;
  41. }
  42. const opts = shared.extend({
  43. hoistStatic: true,
  44. onError: undefined,
  45. onWarn: shared.NOOP
  46. }, options);
  47. if (!opts.isCustomElement && typeof customElements !== 'undefined') {
  48. opts.isCustomElement = tag => !!customElements.get(tag);
  49. }
  50. const { code } = compilerDom.compile(template, opts);
  51. // The wildcard import results in a huge object with every export
  52. // with keys that cannot be mangled, and can be quite heavy size-wise.
  53. // In the global build we know `Vue` is available globally so we can avoid
  54. // the wildcard object.
  55. const render = (new Function('Vue', code)(runtimeDom__namespace));
  56. render._rc = true;
  57. return (compileCache[key] = render);
  58. }
  59. runtimeDom.registerRuntimeCompiler(compileToFunction);
  60. Object.keys(runtimeDom).forEach(function (k) {
  61. if (k !== 'default') exports[k] = runtimeDom[k];
  62. });
  63. exports.compile = compileToFunction;