Skip to content

Commit

Permalink
JavaScript: use this as default _root only in top-level types
Browse files Browse the repository at this point in the history
See the same change in Lua: 1a0b2c0

This would have fixed the `NestedTypesImport` test for JavaScript if it
weren't for the missing import of `NestedTypes3` it uses (in other
words, this test still fails only because of
kaitai-io/kaitai_struct#703).
  • Loading branch information
generalmimon committed Apr 5, 2024
1 parent 1a0b2c0 commit 45f3da2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.inc
out.puts("this._io = _io;")
out.puts("this._parent = _parent;")
out.puts("this._root = _root || this;")
if (name == rootClassName) {
out.puts("this._root = _root || this;")
} else {
out.puts("this._root = _root;")
}

if (isHybrid)
out.puts("this._is_le = _is_le;")
Expand Down

0 comments on commit 45f3da2

Please sign in to comment.