1
0
Fork 0

[assert] lowercase in some assertions for outerHTML and innerHTML

This commit is contained in:
Witold Filipczyk 2024-05-08 15:57:56 +02:00
parent ea2dbb05e2
commit e11b52b496
12 changed files with 15 additions and 16 deletions

View File

@ -17,7 +17,7 @@ First Name: <input name="fname" type="text" value="Doug">
<script>
function myFunction() {
var x = document.anchors.item(1).outerHTML;
console.assert(x === '<A href="/home" name="bbb">/home</A>', 'anchors');
console.assert(x === '<a href="/home" name="bbb">/home</a>', 'anchors');
}
console.error('document.anchors.html');

View File

@ -12,7 +12,7 @@
<script>
function myFunction() {
var x = document.documentElement.innerHTML;
console.assert(x.startsWith('<HEAD></HEAD><BODY id="test">'), 'head was added');
console.assert(x.startsWith('<head></head><body id="test">'), 'head was added');
}
console.error('document.documentElement.html');

View File

@ -14,7 +14,7 @@ First Name: <input name="fname" type="text" value="Doug">
<script>
function myFunction() {
var x = document.getElementsByTagName("P").item(1).outerHTML;
console.assert(x === '<P id="demo"></P>', 'demo');
console.assert(x === '<p id="demo"></p>', 'demo');
}
console.error('document.getElementsByTagName.html');

View File

@ -19,7 +19,7 @@ function myFunction() {
var textnode = document.createTextNode("Water");
node.appendChild(textnode);
document.getElementById("myList").appendChild(node);
console.assert(document.getElementsByTagName("UL")[0].outerHTML === '<UL id="myList">\n <LI>Coffee</LI>\n <LI>Tea</LI>\n<LI>Water</LI></UL>', 'Water');
console.assert(document.getElementsByTagName("UL")[0].outerHTML === '<ul id="myList">\n <li>Coffee</li>\n <li>Tea</li>\n<li>Water</li></ul>', 'Water');
}
console.error('element.appendChild.html');
myFunction();

View File

@ -14,10 +14,10 @@
<script>
function myFunction() {
var itm = document.getElementById("myList2").lastChild;
console.assert(itm.outerHTML === '<LI>Milk</LI>', 'Milk');
console.assert(itm.outerHTML === '<li>Milk</li>', 'Milk');
var cln = itm.cloneNode(true);
document.getElementById("myList1").appendChild(cln);
console.assert(document.getElementById("myList1").innerHTML === '<LI>Coffee</LI><LI>Tea</LI><LI>Milk</LI>', 'Coffee, Tea, Milk');
console.assert(document.getElementById("myList1").innerHTML === '<li>Coffee</li><li>Tea</li><li>Milk</li>', 'Coffee, Tea, Milk');
}
console.error('element.cloneNode.html');

View File

@ -13,8 +13,7 @@ var element = document.getElementById("myElement");
var closes2 = element.closest("div.container");
console.error('element.closest.html');
console.assert(closes2, 'not null');
//console.assert(closes2.outerHTML === '<DIV class="demo container">Parent\n <DIV id="myElement" class="demo">The outer HTML of closest element will be shown.</DIV>\n </DIV>', 'TODO');
console.assert(closes2 != null, 'not null');
closes2 = element.closest("p.test");
console.assert(closes2 === null, 'NULL');

View File

@ -9,7 +9,7 @@
function aa()
{
var x = document.getElementById('blabla').firstElementChild.outerHTML;
console.assert(x === '<B id="b1">AAA</B>', 'B');
console.assert(x === '<b id="b1">AAA</b>', 'B');
}
console.error('element.firstElementChild');

View File

@ -14,7 +14,7 @@ First Name: <input name="fname" type="text" value="Doug">
<script>
function myFunction() {
var x = document.getElementById('body').getElementsByTagName("P").item(0).outerHTML;
console.assert(x === '<P>Click the button to get the tag name of the first element in the body that has tag P.</P>', 'first p');
console.assert(x === '<p>Click the button to get the tag name of the first element in the body that has tag P.</p>', 'first p');
}
console.error('element.getElementByTagName.html');

View File

@ -10,7 +10,7 @@
function aa()
{
var a1 = document.getElementById('blabla').innerHTML;
console.assert(a1 === '\n<B>AAA</B><U id="ble">UUU</U>AAAAAAA\n', a1);
console.assert(a1 === '\n<b>AAA</b><u id="ble">UUU</u>AAAAAAA\n', a1);
var a2 = document.getElementById('ble').innerHTML;
console.assert(a2 === 'UUU', 'UUU');
}
@ -19,7 +19,7 @@ function bb()
{
document.getElementById('blabla').innerHTML = '<u>test</u><b>OK</b>';
var b1 = document.getElementById('blabla').outerHTML;
console.assert(b1 === '<A id="blabla" href="/"><U>test</U><B>OK</B></A>', 'Changed');
console.assert(b1 === '<a id="blabla" href="/"><u>test</u><b>OK</b></a>', 'Changed');
}
console.error('element.innerHTML.html');

View File

@ -21,7 +21,7 @@ function myFunction() {
var list = document.getElementById("myList");
list.insertBefore(newItem, list.firstChild);
var result = document.getElementsByTagName("UL")[0].outerHTML;
console.assert(result === '<UL id="myList"><LI>Water</LI>\n <LI>Coffee</LI>\n <LI>Tea</LI>\n</UL>', 'Water, Coffee, Tea');
console.assert(result === '<ul id="myList"><li>Water</li>\n <li>Coffee</li>\n <li>Tea</li>\n</ul>', 'Water, Coffee, Tea');
}
console.error('element.insertBefore.html');

View File

@ -9,7 +9,7 @@
function aa()
{
var x = document.getElementById('blabla').lastElementChild.outerHTML;
console.assert(x === '<U dir="auto" id="ble" title="test">UUU</U>', 'u');
console.assert(x === '<u dir="auto" id="ble" title="test">UUU</u>', 'u');
}
console.error('element.lastElementChild.html');

View File

@ -18,10 +18,10 @@
<script>
function myFunction() {
var before = document.getElementsByTagName("H1")[0].outerHTML;
console.assert(before === '<H1>Hello World</H1>', 'H1');
console.assert(before === '<h1>Hello World</h1>', 'H1');
document.getElementsByTagName("H1")[0].setAttribute("class", "democlass");
var after = document.getElementsByTagName("H1")[0].outerHTML;
console.assert(after === '<H1 class="democlass">Hello World</H1>', 'H1 with class');
console.assert(after === '<h1 class="democlass">Hello World</h1>', 'H1 with class');
}
console.error("element.setAttribute.html");
myFunction();