From 86e7236f11143a323f33110e2ad1bfebf61e3c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ro=C5=BCek?= Date: Sun, 4 Feb 2024 23:29:39 +0100 Subject: [PATCH] refactor(runtime): drop dead branches in Sandbox#push method --- src/runtime/sandbox.mjs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/runtime/sandbox.mjs b/src/runtime/sandbox.mjs index e3b0a84..8eee4bb 100644 --- a/src/runtime/sandbox.mjs +++ b/src/runtime/sandbox.mjs @@ -1,5 +1,3 @@ -import isObject from './codegen-functions/is-object.mjs'; - function printSegment(path, segment) { return path + `[${typeof segment === 'string' ? `'${segment}'` : segment}]`; } @@ -50,13 +48,8 @@ export class Sandbox { push() { const length = this.#path.length; - - this.property = length === 0 ? null : this.#path[length - 1]; - - const root = - this.property !== null && isObject(this.value) - ? this.value[this.property] - : null; + this.property = this.#path[length - 1]; + const root = this.value[this.property]; if (length + 1 > this.#history.length) { this.#history.push(root);