-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
PHP Version
8.3
CodeIgniter4 Version
4.6.3
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter
)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
No response
What happened?
I get this error in the browser console when using the debug toolbar to highlight views:
Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
at showHints (<anonymous>:459:34)
at btn.parentNode.onclick (<anonymous>:514:17)
In the loop over sortedComments
, the end
variable gets shared between different iterations of the loop.
In some iterations, start
is equal with childArray.length
, so end
is not given a new value and keeps the one from the previous iteration.
If the previous value was larger than start
, this results in an attempt to read from beyond the end of childArray
, so debugDiv.appendChild()
is called with undefined
.
Steps to Reproduce
app/Views/page.php:
<?= view('header') ?>
<?= $content ?>
<?= view('footer') ?>
app/Views/header.php:
<body>
<div>
app/Views/footer.php:
</div>
</body>
app/Views/inner.php:
<div></div>
any controller:
return view('page', ['content' => view('inner')]);
Render the view, then click on "Views" in the debug toolbar
Expected Output
No error
Anything else?
Using let start, end
instead of var start, end
seems to fix the issue by preventing the variables from "leaking" across iterations.
I intend to submit a PR that fixes this.