<!DOCTYPE html> | |
<style> | |
#target::before { content: "FAIL (string) "; } | |
</style> | |
<div id="target" my-attr="FAIL (attribute) ">test</div> | |
<script> | |
onload = function(){ | |
var s = document.createElement("style"); | |
s.textContent = "#target::before { content: attr(my-attr); }" | |
var head = document.querySelector("head"); | |
head.appendChild(s); | |
target.offsetTop; | |
target.setAttribute("my-attr", "PASS "); | |
}; | |
</script> |