Skip to content

Conversation

@unity
Copy link

@unity unity commented May 25, 2015

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:

@vvo
Copy link

vvo commented Sep 15, 2015

HI @unity How do you pass the corresponding element in the webpack config? Thanks

@unity
Copy link
Author

unity commented Sep 15, 2015

You pass it at runtime :

import style from './style.css'

style.use(document.getElementById('myId'));

@mrshll
Copy link

mrshll commented Oct 21, 2015

is there any chance this will be merged? Would love to use this for iframes

@ronkorving
Copy link

Currently this PR has conflicts. Rebasing would be a good start. Would like to see this merged too.


function createStyleElement() {
function createStyleElement(element) {
var styleElement = document.createElement("style");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

styleElement => style

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parentElement => element

Copy link
Member

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 :)

@bebraw
Copy link

bebraw commented Mar 6, 2017

Could you rebase and add tests where possible? Thanks.

getHeadElement = memoize(function () {
return document.head || document.getElementsByTagName("head")[0];
}),
getElement = function (element) {
Copy link
Contributor

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.

@michael-ciniawsky
Copy link
Member

Superseded by #135 Thx 😛

@Aqours
Copy link

Aqours commented Dec 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants