vue.cjs.prod.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 { code } = compilerDom.compile(template, shared.extend({
  43. hoistStatic: true,
  44. onError: undefined,
  45. onWarn: shared.NOOP
  46. }, options));
  47. // The wildcard import results in a huge object with every export
  48. // with keys that cannot be mangled, and can be quite heavy size-wise.
  49. // In the global build we know `Vue` is available globally so we can avoid
  50. // the wildcard object.
  51. const render = (new Function('Vue', code)(runtimeDom__namespace));
  52. render._rc = true;
  53. return (compileCache[key] = render);
  54. }
  55. runtimeDom.registerRuntimeCompiler(compileToFunction);
  56. Object.keys(runtimeDom).forEach(function (k) {
  57. if (k !== 'default') exports[k] = runtimeDom[k];
  58. });
  59. exports.compile = compileToFunction;