扫一扫分享
SentinelJS is a tiny JavaScript library that makes it easy to set up a watch function that will notify you anytime a new node is added to the dom that matches a given css rule. Among other things, you can take advantage of this to implement custom-elements and make other in-place modifications to new DOM elements:
<script>
sentinel.on('custom-element', function(el) {
// A new <custom-element> has been detected
el.innerhtml = 'The sentinel is always watching.';
});
</script>
<custom-element></custom-element>
手机预览