MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / compareHTML

Function compareHTML

static/js/learnpython.js:79–117  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

77}
78
79function compareHTML(a, b) {
80 // TODO - check CSS
81 // TODO - check head
82
83 if (a.children.length !== b.children.length) {
84 return false;
85 }
86
87 for (let i = 0; i < a.children.length; i++) {
88 // first check that the tag name is similar
89 if (a.children[i].tagName !== b.children[i].tagName) {
90 return false;
91 }
92
93 // check attributes - TODO
94 if (a.children[i].attributes.length !== b.children[i].attributes.length) {
95 return false;
96 }
97
98 for (let j = 0; j < a.children[i].attributes.length; j++) {
99 let attribute = a.children[i].attributes[j].name;
100 if (a.children[i].attributes[attribute].value !== b.children[i].attributes[attribute].value) {
101 return false;
102 }
103 }
104
105 if (a.children[i].children.length === 0) {
106 if (a.children[i].innerHTML !== b.children[i].innerHTML) {
107 return false;
108 }
109 } else {
110 if (!compareHTML(a.children[i], b.children[i])) {
111 return false;
112 }
113 }
114 }
115
116 return true;
117}
118
119function execute() {
120 maximizeDock();

Callers 1

executeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected