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

Update core.imba with rel='preload' option for styles #670

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/imba/src/imba/dom/core.imba
Expand Up @@ -797,6 +797,17 @@ export class HTMLStyleElement < HTMLElement
get src
#src

set rel value
if #rel =? value
yes
return

get rel
#rel

get is_preload
"{#rel}".match 'preload'

get outerHTML
if HtmlContext and src
(HtmlContext.styles||=[]).push(self)
Expand All @@ -807,6 +818,12 @@ export class HTMLStyleElement < HTMLElement
setAttribute('rel','stylesheet')
setAttribute('href',String(src))
let out = super
if is_preload
setAttribute('rel','preload')
setAttribute('as','style')
let preloadOut = super
nodeName = 'style'
return "{preloadOut}{out}"
nodeName = 'style'
return out

Expand Down Expand Up @@ -977,4 +994,4 @@ export def defineTag name, klass, options = {}
global.#dom = {
Location: Location
Document: Document
}
}