Skip to content
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

Possibility to specify type attribute #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions src/insertCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function removeCss(ids) {
* // Remove it from the DOM
* removeCss();
*/
function insertCss(styles, { replace = false, prepend = false, prefix = 's' } = {}) {
function insertCss(styles, { replace = false, prepend = false, prefix = 's', type } = {}) {
const ids = []
for (let i = 0; i < styles.length; i++) {
const [moduleId, css, media, sourceMap] = styles[i]
Expand All @@ -66,7 +66,8 @@ function insertCss(styles, { replace = false, prepend = false, prefix = 's' } =
create = true

elem = document.createElement('style')
elem.setAttribute('type', 'text/css')
if (type === undefined || typeof type === 'string')
elem.setAttribute('type', type || 'text/css')
Comment on lines +69 to +70
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (type === undefined || typeof type === 'string')
elem.setAttribute('type', type || 'text/css')
if (!type || typeof type === 'string') {
elem.setAttribute('type', type || 'text/css')
}

elem.id = id

if (media) {
Expand Down