yumemi/front/attr

型付きの属性(0.12、51 v6「属性の型」)。名前は固定で、値から名前を作れるのは data と aria だけ(名は [a-z][a-z0-9-]*、外れた名の属性は出さない)。名前を自由に渡す口・class・ style・on* は置かない。名前と引数の順は lustre の attribute に揃える。

Types

pub type Role {
  Alert
  Button
  Dialog
  Group
  List
  Listitem
  Radio
  Radiogroup
  Status
  Textbox
  Toolbar
}

Constructors

  • Alert
  • Button
  • Dialog
  • Group
  • List
  • Listitem
  • Radio
  • Radiogroup
  • Status
  • Textbox
  • Toolbar

iframe の sandbox の許しの語(HTML の仕様の語のうち、Chromium の sandbox.supports が通す 12 語、0.16.0)。 字の素通しは置かない。allow-top-navigation-to-custom-protocols は Chromium が知らない語なので入れない。

pub type Sandbox {
  AllowDownloads
  AllowForms
  AllowModals
  AllowOrientationLock
  AllowPointerLock
  AllowPopups
  AllowPopupsToEscapeSandbox
  AllowPresentation
  AllowSameOrigin
  AllowScripts
  AllowTopNavigation
  AllowTopNavigationByUserActivation
}

Constructors

  • AllowDownloads
  • AllowForms
  • AllowModals
  • AllowOrientationLock
  • AllowPointerLock
  • AllowPopups
  • AllowPopupsToEscapeSandbox
  • AllowPresentation
  • AllowSameOrigin
  • AllowScripts
  • AllowTopNavigation
  • AllowTopNavigationByUserActivation

Values

pub fn accept(values: List(String)) -> el.Attribute
pub fn action(value: String) -> el.Attribute

action。href と同じ柵(送信で javascript: の URL が走るため)。

pub fn alt(value: String) -> el.Attribute
pub fn aria(name: String, value: String) -> el.Attribute

aria-<name>。名の扱いは data と同じ。

pub fn aria_controls(value: String) -> el.Attribute
pub fn aria_expanded(on: Bool) -> el.Attribute
pub fn aria_haspopup(value: String) -> el.Attribute
pub fn aria_hidden(on: Bool) -> el.Attribute
pub fn aria_label(value: String) -> el.Attribute
pub fn checked(on: Bool) -> el.Attribute
pub fn d(value: String) -> el.Attribute
pub fn data(name: String, value: String) -> el.Attribute

data-<name>。名が [a-z][a-z0-9-]* でなければ出さない(頁を落とさない)。

yumemi で始まる名は出さない(0.12 段 C)── data-yumemi-* は framework と runtime の印で、★ が 書けると送り先・状態・逃げ道の印を偽れる。生成器も第 7 条で止める。

pub fn disabled(on: Bool) -> el.Attribute
pub fn fill(value: String) -> el.Attribute
pub fn focusable(on: Bool) -> el.Attribute
pub fn for(value: String) -> el.Attribute
pub fn height(value: Int) -> el.Attribute
pub fn hidden(on: Bool) -> el.Attribute
pub fn href(value: String) -> el.Attribute

href。scheme が http・https・mailto・tel か相対(scheme の無い値)でなければ出さない (javascript: の URL を escape は止めないため。DB から来る URL の柵)。

pub fn id(value: String) -> el.Attribute
pub fn inputmode(value: String) -> el.Attribute
pub fn label(value: String) -> el.Attribute
pub fn loading(value: String) -> el.Attribute
pub fn maxlength(value: Int) -> el.Attribute
pub fn method(value: String) -> el.Attribute
pub fn min(value: String) -> el.Attribute
pub fn minlength(value: Int) -> el.Attribute
pub fn name(value: String) -> el.Attribute
pub fn none() -> el.Attribute

何も出さない属性。

pub fn placeholder(value: String) -> el.Attribute
pub fn readonly(on: Bool) -> el.Attribute
pub fn referrerpolicy(value: String) -> el.Attribute
pub fn rel(value: String) -> el.Attribute
pub fn required(on: Bool) -> el.Attribute
pub fn role(role: Role) -> el.Attribute
pub fn rows(value: Int) -> el.Attribute
pub fn safe_url(value: String) -> Bool

scheme が http・https・mailto・tel か、scheme の無い相対の URL か。scheme は最初の : の 前で、そこまでに /・?・# があれば相対。HTML の URL の parser が捨てる先頭と末尾の 空白・制御文字と、途中のタブ・改行は除いてから見る。

pub fn sandbox(allows: List(Sandbox)) -> el.Attribute

sandbox(0.16.0)。許しの語を書いた順に空白で繋ぐ(重なりは 1 つに)。空の list は値の空の sandbox(全部を禁じる。 el.to_string は値の空の属性を名だけで書く ── sandbox="" と同じ)。 先が同じ origin の iframe に AllowScripts と AllowSameOrigin を並べると、中の script が sandbox を外せる (HTML の仕様の注意)── 並べるのは別の origin の部品に限る。

pub fn scope(value: String) -> el.Attribute
pub fn selected(on: Bool) -> el.Attribute
pub fn src(value: String) -> el.Attribute

src。href と同じ柵。

pub fn target(value: String) -> el.Attribute
pub fn title(value: String) -> el.Attribute
pub fn type_(value: String) -> el.Attribute
pub fn value(value: String) -> el.Attribute
pub fn view_box(value: String) -> el.Attribute

SVG の属性(試作では icon に要る 4 つだけ)。

pub fn width(value: Int) -> el.Attribute
✨ Search Document