diff options
author | bptato <nincsnevem662@gmail.com> | 2022-10-19 11:51:06 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2022-10-19 11:51:06 +0200 |
commit | ec82803b87aee94be1e44204bf62426df39f3087 (patch) | |
tree | 113ef554f5ebce44563c5406af6be2d5cfe7da32 /src/html | |
parent | 7fbedc1f0d7e58fbbce3bdb469f81e9b7c411c15 (diff) | |
download | chawan-ec82803b87aee94be1e44204bf62426df39f3087.tar.gz |
Re-enable media queries
Diffstat (limited to 'src/html')
-rw-r--r-- | src/html/dom.nim | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim index acfe2a22..51a4058b 100644 --- a/src/html/dom.nim +++ b/src/html/dom.nim @@ -164,6 +164,10 @@ type ctype*: bool #TODO result + HTMLBaseElement* = ref object of HTMLElement + + HTMLAreaElement* = ref object of HTMLElement + proc tostr(ftype: enum): string = return ($ftype).split('_')[1..^1].join("-").tolower() @@ -643,6 +647,8 @@ func newHTMLElement*(document: Document, tagType: TagType, namespace = Namespace of TAG_SCRIPT: result = new(HTMLScriptElement) HTMLScriptElement(result).forceAsync = true + of TAG_BASE: + result = new(HTMLBaseElement) else: result = new(HTMLElement) @@ -727,18 +733,19 @@ func baseUrl*(document: Document): Url = return document.location return url.get -func href*(element: Element): string = - assert element.tagType in {TAG_A, TAG_LINK, TAG_BASE} +func href*[T: HTMLAnchorElement|HTMLLinkElement|HTMLBaseElement](element: T): string = if element.attrb("href"): let url = parseUrl(element.attr("href"), some(element.document.location)) if url.issome: return $url.get return "" -func rel*(element: Element): string = - assert element.tagType in {TAG_A, TAG_LINK, TAG_AREA} +func rel*[T: HTMLAnchorElement|HTMLLinkElement|HTMLAreaElement](element: T): string = return element.attr("rel") +func media*[T: HTMLLinkElement|HTMLStyleElement](element: T): string = + return element.attr("media") + func title*(document: Document): string = for title in document.elements(TAG_TITLE): return title.childTextContent.stripAndCollapse() |