xslt-processor 5.0.0 → 5.0.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.
package/index.mjs CHANGED
@@ -11853,28 +11853,37 @@ var NodeConverter = class {
11853
11853
  */
11854
11854
  convertVariables(exprContext) {
11855
11855
  const variables = {};
11856
- for (const [name, value] of Object.entries(exprContext.variables || {})) {
11857
- if (value && typeof value === "object" && "stringValue" in value) {
11858
- const nodeValue = value;
11859
- if (nodeValue.type === "node-set") {
11860
- variables[name] = value.nodeSetValue().map((n) => this.adaptXNode(n));
11861
- } else if (nodeValue.type === "string") {
11862
- variables[name] = value.stringValue();
11863
- } else if (nodeValue.type === "number") {
11864
- variables[name] = value.numberValue();
11865
- } else if (nodeValue.type === "boolean") {
11866
- variables[name] = value.booleanValue();
11867
- } else if (nodeValue.type === "map") {
11868
- variables[name] = nodeValue.value;
11869
- } else if (nodeValue.type === "array") {
11870
- variables[name] = nodeValue.value;
11871
- } else if (nodeValue.type === "function") {
11872
- variables[name] = nodeValue.value;
11856
+ const contexts = [];
11857
+ let ctx = exprContext;
11858
+ while (ctx) {
11859
+ contexts.push(ctx);
11860
+ ctx = ctx.parent;
11861
+ }
11862
+ for (let i = contexts.length - 1; i >= 0; i--) {
11863
+ const current = contexts[i];
11864
+ for (const [name, value] of Object.entries(current.variables || {})) {
11865
+ if (value && typeof value === "object" && "stringValue" in value) {
11866
+ const nodeValue = value;
11867
+ if (nodeValue.type === "node-set") {
11868
+ variables[name] = value.nodeSetValue().map((n) => this.adaptXNode(n));
11869
+ } else if (nodeValue.type === "string") {
11870
+ variables[name] = value.stringValue();
11871
+ } else if (nodeValue.type === "number") {
11872
+ variables[name] = value.numberValue();
11873
+ } else if (nodeValue.type === "boolean") {
11874
+ variables[name] = value.booleanValue();
11875
+ } else if (nodeValue.type === "map") {
11876
+ variables[name] = nodeValue.value;
11877
+ } else if (nodeValue.type === "array") {
11878
+ variables[name] = nodeValue.value;
11879
+ } else if (nodeValue.type === "function") {
11880
+ variables[name] = nodeValue.value;
11881
+ } else {
11882
+ variables[name] = value.stringValue();
11883
+ }
11873
11884
  } else {
11874
- variables[name] = value.stringValue();
11885
+ variables[name] = value;
11875
11886
  }
11876
- } else {
11877
- variables[name] = value;
11878
11887
  }
11879
11888
  }
11880
11889
  return variables;
@@ -12467,7 +12476,7 @@ var ExprContext = class _ExprContext {
12467
12476
  this.xsltVersion,
12468
12477
  typeof opt_position !== "undefined" ? opt_position : this.position,
12469
12478
  this.decimalFormatSettings,
12470
- this.variables,
12479
+ Object.create(this.variables || {}),
12471
12480
  this.knownNamespaces,
12472
12481
  this,
12473
12482
  this.caseInsensitive,