@tolgee/core 2.8.0 → 2.8.1

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.
@@ -131,23 +131,6 @@
131
131
  var NodeHelper = /** @class */ (function () {
132
132
  function NodeHelper() {
133
133
  }
134
- NodeHelper.evaluateGenerator = function (expression, targetNode) {
135
- var node, evaluated;
136
- return __generator(this, function (_a) {
137
- switch (_a.label) {
138
- case 0:
139
- evaluated = document.evaluate(expression, targetNode, undefined, XPathResult.ANY_TYPE);
140
- _a.label = 1;
141
- case 1:
142
- if (!((node = evaluated.iterateNext()) !== null)) return [3 /*break*/, 3];
143
- return [4 /*yield*/, node];
144
- case 2:
145
- _a.sent();
146
- return [3 /*break*/, 1];
147
- case 3: return [2 /*return*/];
148
- }
149
- });
150
- };
151
134
  NodeHelper.evaluate = function () {
152
135
  var args = [];
153
136
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -197,13 +180,31 @@
197
180
  return true;
198
181
  }
199
182
  if (node instanceof Attr) {
200
- var ownerContainsAttr = Object.values(node.ownerElement.attributes).indexOf(node) > -1;
183
+ var ownerContainsAttr = node.ownerElement &&
184
+ Object.values(node.ownerElement.attributes).indexOf(node) > -1;
201
185
  if (descendant.contains(node.ownerElement) && ownerContainsAttr) {
202
186
  return true;
203
187
  }
204
188
  }
205
189
  return false;
206
190
  };
191
+ NodeHelper.evaluateGenerator = function (expression, targetNode) {
192
+ var node, evaluated;
193
+ return __generator(this, function (_a) {
194
+ switch (_a.label) {
195
+ case 0:
196
+ evaluated = document.evaluate(expression, targetNode, undefined, XPathResult.ANY_TYPE);
197
+ _a.label = 1;
198
+ case 1:
199
+ if (!((node = evaluated.iterateNext()) !== null)) return [3 /*break*/, 3];
200
+ return [4 /*yield*/, node];
201
+ case 2:
202
+ _a.sent();
203
+ return [3 /*break*/, 1];
204
+ case 3: return [2 /*return*/];
205
+ }
206
+ });
207
+ };
207
208
  return NodeHelper;
208
209
  }());
209
210
 
@@ -1597,8 +1598,8 @@
1597
1598
  }
1598
1599
 
1599
1600
  var _a;
1600
- var SPACE_SEPARATOR_START_REGEX = new RegExp("^" + SPACE_SEPARATOR_REGEX.source + "*");
1601
- var SPACE_SEPARATOR_END_REGEX = new RegExp(SPACE_SEPARATOR_REGEX.source + "*$");
1601
+ var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
1602
+ var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
1602
1603
  function createLocation(start, end) {
1603
1604
  return { start: start, end: end };
1604
1605
  }
@@ -1845,7 +1846,7 @@
1845
1846
  return {
1846
1847
  val: {
1847
1848
  type: TYPE.literal,
1848
- value: "<" + tagName + "/>",
1849
+ value: "<".concat(tagName, "/>"),
1849
1850
  location: createLocation(startPosition, this.clonePosition()),
1850
1851
  },
1851
1852
  err: null,
@@ -2450,7 +2451,7 @@
2450
2451
  }
2451
2452
  var code = codePointAt(this.message, offset);
2452
2453
  if (code === undefined) {
2453
- throw Error("Offset " + offset + " is at invalid UTF-16 code unit boundary");
2454
+ throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
2454
2455
  }
2455
2456
  return code;
2456
2457
  };
@@ -2518,7 +2519,7 @@
2518
2519
  */
2519
2520
  Parser.prototype.bumpTo = function (targetOffset) {
2520
2521
  if (this.offset() > targetOffset) {
2521
- throw Error("targetOffset " + targetOffset + " must be greater than or equal to the current offset " + this.offset());
2522
+ throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
2522
2523
  }
2523
2524
  targetOffset = Math.min(targetOffset, this.message.length);
2524
2525
  while (true) {
@@ -2527,7 +2528,7 @@
2527
2528
  break;
2528
2529
  }
2529
2530
  if (offset > targetOffset) {
2530
- throw Error("targetOffset " + targetOffset + " is at invalid UTF-16 code unit boundary");
2531
+ throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
2531
2532
  }
2532
2533
  this.bump();
2533
2534
  if (this.isEOF()) {
@@ -2993,28 +2994,28 @@
2993
2994
  return _this;
2994
2995
  }
2995
2996
  FormatError.prototype.toString = function () {
2996
- return "[formatjs Error: " + this.code + "] " + this.message;
2997
+ return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
2997
2998
  };
2998
2999
  return FormatError;
2999
3000
  }(Error));
3000
3001
  var InvalidValueError = /** @class */ (function (_super) {
3001
3002
  __extends(InvalidValueError, _super);
3002
3003
  function InvalidValueError(variableId, value, options, originalMessage) {
3003
- return _super.call(this, "Invalid values for \"" + variableId + "\": \"" + value + "\". Options are \"" + Object.keys(options).join('", "') + "\"", ErrorCode.INVALID_VALUE, originalMessage) || this;
3004
+ return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
3004
3005
  }
3005
3006
  return InvalidValueError;
3006
3007
  }(FormatError));
3007
3008
  var InvalidValueTypeError = /** @class */ (function (_super) {
3008
3009
  __extends(InvalidValueTypeError, _super);
3009
3010
  function InvalidValueTypeError(value, type, originalMessage) {
3010
- return _super.call(this, "Value for \"" + value + "\" must be of type " + type, ErrorCode.INVALID_VALUE, originalMessage) || this;
3011
+ return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
3011
3012
  }
3012
3013
  return InvalidValueTypeError;
3013
3014
  }(FormatError));
3014
3015
  var MissingValueError = /** @class */ (function (_super) {
3015
3016
  __extends(MissingValueError, _super);
3016
3017
  function MissingValueError(variableId, originalMessage) {
3017
- return _super.call(this, "The intl string context variable \"" + variableId + "\" was not provided to the string \"" + originalMessage + "\"", ErrorCode.MISSING_VALUE, originalMessage) || this;
3018
+ return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
3018
3019
  }
3019
3020
  return MissingValueError;
3020
3021
  }(FormatError));
@@ -3175,7 +3176,7 @@
3175
3176
  continue;
3176
3177
  }
3177
3178
  if (isPluralElement(el)) {
3178
- var opt = el.options["=" + value];
3179
+ var opt = el.options["=".concat(value)];
3179
3180
  if (!opt) {
3180
3181
  if (!Intl.PluralRules) {
3181
3182
  throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
@@ -3721,11 +3722,13 @@
3721
3722
  }
3722
3723
  };
3723
3724
  MouseEventHandler.prototype.onMouseOut = function (element) {
3725
+ element._tolgee.preventClean = false;
3724
3726
  this.mouseOn.delete(element);
3725
3727
  this.mouseOnChanged.emit(this.getMouseOn());
3726
3728
  };
3727
3729
  MouseEventHandler.prototype.onMouseOver = function (element) {
3728
3730
  this.filterMouseOn();
3731
+ element._tolgee.preventClean = true;
3729
3732
  this.mouseOn.delete(element); //to get in to last place
3730
3733
  this.mouseOn.add(element);
3731
3734
  this.mouseOnChanged.emit(this.getMouseOn());
@@ -3953,10 +3956,12 @@
3953
3956
  try {
3954
3957
  for (var _b = __values(this.registeredElements), _c = _b.next(); !_c.done; _c = _b.next()) {
3955
3958
  var element = _c.value;
3956
- this.cleanElementInactiveNodes(element);
3957
- if (element._tolgee.nodes.size === 0 &&
3958
- !element._tolgee.wrappedWithElementOnlyKey) {
3959
- this.cleanElement(element);
3959
+ if (!element._tolgee.preventClean) {
3960
+ this.cleanElementInactiveNodes(element);
3961
+ if (element._tolgee.nodes.size === 0 &&
3962
+ !element._tolgee.wrappedWithElementOnlyKey) {
3963
+ this.cleanElement(element);
3964
+ }
3960
3965
  }
3961
3966
  }
3962
3967
  }
@@ -4028,12 +4033,14 @@
4028
4033
  }
4029
4034
  };
4030
4035
  ElementRegistrar.prototype.cleanElement = function (element) {
4031
- if (typeof element._tolgee.removeAllEventListeners === 'function') {
4032
- element._tolgee.removeAllEventListeners();
4036
+ if (!element._tolgee.preventClean) {
4037
+ if (typeof element._tolgee.removeAllEventListeners === 'function') {
4038
+ element._tolgee.removeAllEventListeners();
4039
+ }
4040
+ element.removeAttribute(TOLGEE_ATTRIBUTE_NAME);
4041
+ delete element._tolgee;
4042
+ this.registeredElements.delete(element);
4033
4043
  }
4034
- element.removeAttribute(TOLGEE_ATTRIBUTE_NAME);
4035
- delete element._tolgee;
4036
- this.registeredElements.delete(element);
4037
4044
  };
4038
4045
  ElementRegistrar.prototype.getActiveNodes = function (element) {
4039
4046
  var _a, _b, node, e_5_1;