single-spa / single-spa-css

Lifecycle helpers for loading and unmounting css
MIT License
14 stars 7 forks source link

Support link attributes like `crossorigin`? #9

Closed miusuncle closed 3 years ago

joeldenning commented 3 years ago

Yeah I'm open to this. Maybe the best way would be the following?

const lifecycles = singleSpaCss({
  createLink(url) {
    const linkEl = document.createElement('link')
    linkEl.rel = 'stylesheet'
    linkEl.crossOrigin = 'use-credentials'
    linkEl.href = url
    return linkEl
  }
})

The createLink option would allow full control over the link tag. Would you be open to sending in a pull request contributing this to single-spa-css?

miusuncle commented 3 years ago

Yeah. I've sent a pull request.

joeldenning commented 3 years ago

Released in https://github.com/single-spa/single-spa-css/releases/tag/v1.2.0

joeldenning commented 3 years ago

Documented in https://github.com/single-spa/single-spa.js.org/pull/476