Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

Only add <style> to <head> when it doesn't exist #265

Merged
merged 1 commit into from
Apr 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions packages/react-look/modules/api/LookRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ class StyleComponent {
this.el = this.createStyleElement(styleElementId)
}

createStyleElement(styleElementId) {
// if a custom style element is provided
// we can use that one instead of creating our own
if (styleElementId) {
return document.getElementById(styleElementId)
createStyleElement(styleElementId = '_react-look-stylesheet') {
let style = document.getElementById(styleElementId)

if (!style) {
style = document.createElement('style')
style.id = styleElementId
document.head.appendChild(style)
}

const style = document.createElement('style')
style.id = '_react-look-stylesheet'
document.head.appendChild(style)


return style
}

Expand Down