fix module for <link> and <base>

This commit is contained in:
Valentin Gagarin 2024-11-13 15:24:41 +01:00 committed by Valentin Gagarin
parent 153b761c8f
commit 414aeb45ba

View file

@ -30,7 +30,6 @@ let
# TODO: add fields for upstream documentation references # TODO: add fields for upstream documentation references
# TODO: programmatically generate documentation # TODO: programmatically generate documentation
options = with lib; { options = with lib; {
attrs = mkAttrs { };
categories = mkOption { categories = mkOption {
type = types.listOfUnique (types.enum content-categories); type = types.listOfUnique (types.enum content-categories);
}; };
@ -157,6 +156,7 @@ let
imports = [ element ]; imports = [ element ];
options = { options = {
inherit (element-types) html; inherit (element-types) html;
attrs = mkAttrs { };
}; };
config.categories = [ ]; config.categories = [ ];
@ -169,6 +169,7 @@ let
html = { name, ... }: { html = { name, ... }: {
imports = [ element ]; imports = [ element ];
options = { options = {
attrs = mkAttrs { };
inherit (element-types) head body; inherit (element-types) head body;
}; };
@ -182,6 +183,7 @@ let
head = { name, ... }: { head = { name, ... }: {
imports = [ element ]; imports = [ element ];
options = with lib; { options = with lib; {
attrs = mkAttrs { };
# https://html.spec.whatwg.org/multipage/semantics.html#the-head-element:concept-element-content-model # https://html.spec.whatwg.org/multipage/semantics.html#the-head-element:concept-element-content-model
# XXX: this doesn't implement the iframe srcdoc semantics # XXX: this doesn't implement the iframe srcdoc semantics
# as those have questionable value and would complicate things a bit. # as those have questionable value and would complicate things a bit.
@ -289,6 +291,7 @@ let
title = { name, ... }: { title = { name, ... }: {
imports = [ element ]; imports = [ element ];
options.attrs = mkAttrs { };
options.text = mkOption { options.text = mkOption {
type = types.str; type = types.str;
}; };
@ -300,18 +303,17 @@ let
base = { name, ... }: { base = { name, ... }: {
imports = [ element ]; imports = [ element ];
# TODO: "A base element must have either an href attribute, a target attribute, or both." # TODO: "A base element must have either an href attribute, a target attribute, or both."
attrs = mkAttrs { inherit (attrs) href target; }; options = global-attrs // { inherit (attrs) href target; };
config.categories = [ "metadata" ]; config.categories = [ "metadata" ];
config.__toString = self: "<base${print-attrs self}>";
}; };
link = { name, ... }: { link = { name, ... }: {
imports = [ element ]; imports = [ element ];
options = mkAttrs options = mkAttrs {
{ # TODO: more attributes
# TODO: more attributes # https://html.spec.whatwg.org/multipage/semantics.html#the-link-element:concept-element-attributes
# https://html.spec.whatwg.org/multipage/semantics.html#the-link-element:concept-element-attributes inherit (attrs) href;
inherit (attrs) href;
} // {
# XXX: there are variants of `rel` for `link`, `a`/`area`, and `form` # XXX: there are variants of `rel` for `link`, `a`/`area`, and `form`
rel = mkOption { rel = mkOption {
# https://html.spec.whatwg.org/multipage/semantics.html#attr-link-rel # https://html.spec.whatwg.org/multipage/semantics.html#attr-link-rel
@ -344,12 +346,13 @@ let
# TODO: figure out how to make body-ok `link` elements # TODO: figure out how to make body-ok `link` elements
# https://html.spec.whatwg.org/multipage/semantics.html#allowed-in-the-body # https://html.spec.whatwg.org/multipage/semantics.html#allowed-in-the-body
config.categories = [ "metadata" ]; config.categories = [ "metadata" ];
config.__toString = self: "<name${print-attrs self.attrs} />"; config.__toString = self: "<link${print-attrs self}>";
}; };
body = { name, ... }: { body = { name, ... }: {
imports = [ element ]; imports = [ element ];
options = { options = {
attrs = mkAttrs { };
content = mkOption { content = mkOption {
type = with types; type = with types;
# HACK: bail out for now # HACK: bail out for now