66
771 . [ Show the different ways of selecting an element from DOM] ( #Q1 )
881 . [ Show the ways to loop over the Nodelist obtained after querying for the elements] ( #Q2 )
9- 3 . [ Design and Implement a Node Store, which supports DOM element as key] ( #Q3 )
10- 4 . [ Implement a function to find the closest ancestor with the provided selector] ( #Q4 )
11- 5 . [ Write a function to find the corresponding node in two identical DOM trees] ( #Q5 )
12- 6 . [ Write a function to get depth of a given DOM tree] ( #Q6 )
13- 7 . [ Implement a function to get the root node of a given DOM fragment] ( #Q7 )
14- 8 . [ Implement a function to get unique tag names in a given DOM tree] ( #Q8 )
15- 9 . [ Implement a function to check if a given DOM tree has duplicate IDs] ( #Q9 )
9+ 1 . [ Design and Implement a Node Store, which supports DOM element as key] ( #Q3 )
10+ 1 . [ Implement a function to find the closest ancestor with the provided selector] ( #Q4 )
11+ 1 . [ Write a function to find the corresponding node in two identical DOM trees] ( #Q5 )
12+ 1 . [ Write a function to get depth of a given DOM tree] ( #Q6 )
13+ 1 . [ Implement a function to get the root node of a given DOM fragment (document.getRootNode() method)] ( #Q7 )
14+ 1 . [ Implement a function to get the root node of a given DOM fragment] ( #Q8 )
15+ 1 . [ Implement a function to get unique tag names in a given DOM tree] ( #Q9 )
16+ 1 . [ Implement a function to check if a given DOM tree has duplicate IDs] ( #Q10 )
1617
1718---
1819
@@ -50,7 +51,6 @@ Note goes here
5051
5152<br />
5253
53-
5454#### Q3
5555### Design and Implement a Node Store, which supports DOM element as key
5656
@@ -94,7 +94,6 @@ class NodeStore {
9494
9595<br />
9696
97-
9897#### Q4
9998### Implement a function to find the closest ancestor with the provided selector (Element.closest() method)
10099
@@ -141,7 +140,6 @@ A.innerHTML = `
141140<div >
142141</div >`
143142
144-
145143const B = A .cloneNode (true )
146144const node1 = A .querySelector (' #node1' )
147145const node2 = A .querySelector (' #node2' )
@@ -172,7 +170,6 @@ const findCorrespondingNode = (rootA, rootB, target) => {
172170
173171<br />
174172
175-
176173#### Q6
177174### Write a function to get depth of a given DOM tree
178175
@@ -203,13 +200,13 @@ function getHeight (root) {
203200}
204201```
205202
203+ <br >
206204
207205#### Q7
208206### Implement a function to get the root node of a given DOM fragment (document.getRootNode() method)
209207
210208- Root node is the topmost parent node of any given DOM fragment
211209
212-
213210``` js
214211/**
215212 * @param {HTMLElement | null} tree
@@ -229,6 +226,7 @@ function getRootNode (tree) {
229226###### References
230227- https://javascript.info/dom-navigation
231228
229+ <br >
232230
233231#### Q8
234232### Implement a function to get unique tag names in a given DOM tree
@@ -258,11 +256,9 @@ function getUniqueTags(root, result = new Set()) {
258256###### References
259257- https://bigfrontend.dev/problem/get-DOM-tags
260258
259+ <br >
261260
262- <br />
263-
264-
265- #### Q8
261+ #### Q9
266262### Implement a function to get elements by tag name (document.getElementsByTagName() method)
267263
268264- The getElementsByTagName method of Document interface returns an HTMLCollection of elements with the given tag name.
@@ -295,8 +291,7 @@ function getElementsByTagName(root, tagName) {
295291###### References
296292- https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName
297293
298-
299- #### Q9
294+ #### Q10
300295### Implement a function to check if a given DOM tree has duplicate IDs
301296
302297- In a given DOM tree, the id on each node has be unique
@@ -325,5 +320,6 @@ function hasDuplicateId(tree, idSet = new Set()) {
325320}
326321```
327322
323+ <br >
328324
329325[[ ↑] Back to top] ( #home )
0 commit comments