clone-style
v1.0.0
Published
Clone `<style>` tag node right in browser, for IE9+
Downloads
5
Readme
Clone Style
Clone <style>
tag right in browser, for IE9+
Why?
<style>
tag is another world of CSSOM, cannot easily clone using cloneNode
etc, so this lib exists here.
Usage
cloneStyle(styleNode, [docNode], [beforeNode])
styleNode: must be a existing
<style>
node to be cloneddocNode: the document to append the new style node to, or current document if omitted
beforeNode: the place to insert before the new style node, or append to
<head>
if omitted.
Example
const newStyle = cloneStyle($0)
// newStyle now exists in <head>
const newStyle2 = cloneStyle($0, iframeDocument)
// newStyle now exists in iframe <head>
const newStyle2 = cloneStyle($0, iframeDocument, someNode)
// newStyle now exists in iframe before someNode