1.0.0 • Published 6 years ago

clone-style v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

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 cloned

  • docNode: 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