@lingui/macro 3.13.3 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +11 -11
  2. package/macroJsx.js +2 -5
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -56,6 +56,17 @@ function macro(_ref) {
56
56
  var jsxNodes = [];
57
57
  var jsNodes = [];
58
58
  var needsI18nImport = false;
59
+ var alreadyVisitedCache = new WeakSet();
60
+
61
+ var alreadyVisited = function alreadyVisited(path) {
62
+ if (alreadyVisitedCache.has(path)) {
63
+ return true;
64
+ } else {
65
+ alreadyVisitedCache.add(path);
66
+ return false;
67
+ }
68
+ };
69
+
59
70
  Object.keys(references).forEach(function (tagName) {
60
71
  var nodes = references[tagName];
61
72
  var macroType = getMacroType(tagName);
@@ -134,17 +145,6 @@ function isRootPath(allPath) {
134
145
  };
135
146
  }
136
147
 
137
- var alreadyVisitedCache = [];
138
-
139
- function alreadyVisited(path) {
140
- if (alreadyVisitedCache.includes(path)) {
141
- return true;
142
- } else {
143
- alreadyVisitedCache.push(path);
144
- return false;
145
- }
146
- }
147
-
148
148
  function getMacroType(tagName) {
149
149
  switch (tagName) {
150
150
  case "defineMessage":
package/macroJsx.js CHANGED
@@ -67,11 +67,8 @@ var MacroJSX = /*#__PURE__*/function () {
67
67
  (0, _defineProperty2.default)(this, "expressionIndex", void 0);
68
68
  (0, _defineProperty2.default)(this, "elementIndex", void 0);
69
69
  (0, _defineProperty2.default)(this, "safeJsxAttribute", function (name, value) {
70
- // Quoted JSX attributes use XML-style escapes instead of JavaScript-style escapes.
71
- // This means that <Trans id="Say \"hi\"!" /> is invalid, but <Trans id={"Say \"hi\"!"} /> is valid.
72
- // We could consider removing this condition and always wrap in a jsxExpressionContainer.
73
- var attributeValue = value.includes('"') ? _this.types.jsxExpressionContainer(_this.types.stringLiteral(value)) : _this.types.stringLiteral(value);
74
- return _this.types.jsxAttribute(_this.types.jsxIdentifier(name), attributeValue);
70
+ // This handles quoted JSX attributes and html entities.
71
+ return _this.types.jsxAttribute(_this.types.jsxIdentifier(name), _this.types.jsxExpressionContainer(_this.types.stringLiteral(value)));
75
72
  });
76
73
  (0, _defineProperty2.default)(this, "replacePath", function (path) {
77
74
  var tokens = _this.tokenizeNode(path.node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/macro",
3
- "version": "3.13.3",
3
+ "version": "3.15.0",
4
4
  "description": "Macro for generating messages in ICU MessageFormat syntax",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.11.2",
33
- "@lingui/conf": "^3.13.3",
33
+ "@lingui/conf": "^3.15.0",
34
34
  "ramda": "^0.27.1"
35
35
  },
36
36
  "peerDependencies": {