-
-
Notifications
You must be signed in to change notification settings - Fork 469
Allow to specify element into which to inject Style. #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Romain Dardour <[email protected]>
HI @unity How do you pass the corresponding element in the webpack config? Thanks |
You pass it at runtime : import style from './style.css'
style.use(document.getElementById('myId')); |
is there any chance this will be merged? Would love to use this for iframes |
Currently this PR has conflicts. Rebasing would be a good start. Would like to see this merged too. |
@@ -95,11 +95,11 @@ function listToStyles(list) { | |||
return styles; | |||
} | |||
|
|||
function createStyleElement() { | |||
function createStyleElement(element) { | |||
var styleElement = document.createElement("style"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
styleElement
=> style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parentElement
=> element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and all following references to them please :)
Could you rebase and add tests where possible? Thanks. |
getHeadElement = memoize(function () { | ||
return document.head || document.getElementsByTagName("head")[0]; | ||
}), | ||
getElement = function (element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a reason to remove memoization.
Superseded by #135 Thx 😛 |
import style from './style.css'
style.use(parent.document.getElementById('myId')); IMO, this way is more useful than set config in style-loader. Consider to add this feature |
We use this to allow injecting a Style tag into a different place than HEAD.
We use React+Webpack a lot to bundle reusable applications embedded in a 3rd party page.
Here are two examples of how we benefit from this PR: