1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

LibWeb: Implement getting and setting element.innerHTML

Getting the innerHTML property will recurse through the subtree inside
the element and serialize it into a string as it goes.

Setting it will parse the set value as an HTML fragment. It will then
remove all current children of the element and replace them with all
the children inside the parsed fragment.

Setting element.innerHTML will currently force a complete rebuild of
the document's layout tree.

This is pretty neat! :^)
This commit is contained in:
Andreas Kling 2020-03-25 18:53:20 +01:00
parent 632cc53e2c
commit 68b04d5c78
11 changed files with 192 additions and 5 deletions

View file

@ -0,0 +1,17 @@
<!DOCTYPE>
<html>
<head>
</head>
<body>
<div id=clicky style="background-color: red; color: white; border: 1px solid black;">Click me</div>
<div id="foo">This has <b>some HTML</b> inside it!</div>
<script type="text/javascript">
function hax() {
var foo = document.getElementById("foo");
console.log("trying");
foo.innerHTML = 'But now the HTML has changed!';
}
document.getElementById("clicky").addEventListener("mousedown", hax);
</script>
</body>
</html>