transformRef.js 935 B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.transformRef = void 0;
  4. const compiler_core_1 = require("@vue/compiler-core");
  5. const utils_1 = require("../utils");
  6. function transformRef(node, context) {
  7. if (!(0, utils_1.isUserComponent)(node, context)) {
  8. return;
  9. }
  10. addVueRef(node, context);
  11. }
  12. exports.transformRef = transformRef;
  13. function addVueRef(node, context) {
  14. // 仅配置了 ref 属性的,才需要增补 vue-ref
  15. const refProp = (0, compiler_core_1.findProp)(node, 'ref');
  16. if (!refProp) {
  17. return;
  18. }
  19. if (refProp.type === 6 /* NodeTypes.ATTRIBUTE */) {
  20. refProp.name = 'u-' + utils_1.VUE_REF;
  21. }
  22. else {
  23. ;
  24. refProp.arg.content = 'u-' + utils_1.VUE_REF;
  25. }
  26. return (0, utils_1.addStaticClass)(node,
  27. // ref-in-for
  28. // ref
  29. context.inVFor
  30. ? utils_1.VUE_REF_IN_FOR
  31. : utils_1.VUE_REF);
  32. }