Skip to content

Replace the remaining Node.removeChild() instances with Element.remove() #14278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

Using Element.remove() is a slightly more compact way of removing an element, since you no longer need to explicitly find/use its parent element.
Furthermore, the patch also replaces a couple of loops that're used to delete all elements under a node with simply overwriting the contents directly (a pattern already used throughout the viewer).

See also:

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/ce903bed515ba22/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/f0a974663d2ecae/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/f0a974663d2ecae/output.txt

Total script time: 23.77 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 11
  different first/second rendering: 3

Image differences available at: http://54.241.84.105:8877/f0a974663d2ecae/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/ce903bed515ba22/output.txt

Total script time: 42.04 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 4
  different first/second rendering: 2

Image differences available at: http://54.193.163.58:8877/ce903bed515ba22/reftest-analyzer.html#web=eq.log

@SamyCookie
Copy link

SamyCookie commented Nov 16, 2021

@Snuffleupagus You can activate the eslint rule unicorn/prefer-dom-node-remove to reinforce that way.

cf. https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-remove.md

@Snuffleupagus Snuffleupagus force-pushed the rm-removeChild branch 2 times, most recently from fcaaf19 to 4d37a03 Compare November 16, 2021 15:05
…move()`

Using `Element.remove()` is a slightly more compact way of removing an element, since you no longer need to explicitly find/use its parent element.
Furthermore, the patch also replaces a couple of loops that're used to delete all elements under a node with simply overwriting the contents directly (a pattern already used throughout the viewer).

See also:
 - https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/remove
@timvandermeij timvandermeij merged commit 3dccacc into mozilla:master Nov 17, 2021
@timvandermeij
Copy link
Contributor

Nice work; thanks both!

@Snuffleupagus Snuffleupagus deleted the rm-removeChild branch November 18, 2021 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants