Skip to content

Commit

Permalink
SchemaStack: use .hasExited() consistently (#1257)
Browse files Browse the repository at this point in the history
* SchemaStack: make .exited prop private
* eslint: increase ECMAScript version
  • Loading branch information
alxndrsn authored Nov 3, 2024
1 parent 644fe0f commit 346d78a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "airbnb-base",
"env": { "node": true },
"parserOptions": { "ecmaVersion": 2020 },
"parserOptions": { "ecmaVersion": 2022 },
"plugins": [
"no-only-tests"
],
Expand Down
6 changes: 4 additions & 2 deletions lib/data/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ const getFormFields = (xml) => {
// when processing incoming attachments; we can select only binary fields from
// the database.
class SchemaStack {
#exited;

constructor(fieldList, allowEmptyNavigation = false) {
this.fieldList = fieldList;
this.fields = {};
Expand All @@ -188,7 +190,7 @@ class SchemaStack {
}

head() { return last(this.fieldStack); }
hasExited() { return this.exited === true; }
hasExited() { return this.#exited === true; }

// if you do not give a path to find the children of, the current stack
// path is used.
Expand Down Expand Up @@ -252,7 +254,7 @@ class SchemaStack {
pop() {
// if we have /already/ hit depth 0 and we try to pop again, we must be trying
// to close the wrapper tag, so mark exited as true.
if (this.pathStack.length === 0) this.exited = true;
if (this.pathStack.length === 0) this.#exited = true;
this.path = this.pathStack.pop();
this.iterationStack.pop();
return this.fieldStack.pop();
Expand Down
2 changes: 1 addition & 1 deletion lib/data/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const _hashedTree = (structurals, xml) => {
},
onclosetag: (tagName) => {
const structural = stack.pop();
if (stack.exited === true) {
if (stack.hasExited()) {
// nothing routine to do, but since we are done let's digest the root hash.
tree[subhash] = tree[subhash].digest('base64');
} else if (structural == null) {
Expand Down

0 comments on commit 346d78a

Please sign in to comment.