🥮 mooncakes.io

    #HTML

    The html package provides wrapper functions for all HTML elements. Basic usage:

    ///|
    fn view(emit : Emit[Msg], model : Model) -> Html {
    div(id="counter", style=["border: 1px solid black"], [
    h1(id="title", "the count is \{model.count}"),
    button(class="...", on_click=emit(Inc), "+"),
    button(class="...", on_click=emit(Dec), "-"),
    ])
    }

    Frequently used attributes are exposed as optional arguments. To access any HTML attribute, see Attribute Builder. Most HTML wrappers accept a positional argument whose type is constrained by IsChildren, so you can pass an Array[Html] or a String. See Children for details.

    There are also a few special helpers you will use frequently:

    • text()

      To represent text in HTML, use the text function.

      ///|
      let _ = p([text("hello world")])
      let _ = p("hello world") // equivalent to above

    • nothing

      It does not represent an actual HTML element. This is useful when handling multiple Option values in your model:

      ///|
      fn bad(path : Path, tag : Tag?) {
      let path = foo(path)
      let tag = match tag {
      None => []
      Some(x) => [view(x)] // Yuck!
      }
      div([path] + tag) // Don't do this
      }

      ///|
      fn good(path : Path, tag : Tag?) {
      let path = foo(path)
      let tag = match tag {
      None => nothing
      Some(x) => view(x)
      }
      div([path, tag]) // Use @html.nothing
      }

    #Children

    Almost every HTML element accepts a positional argument whose type is bounded by the IsChildren trait. This means you can pass any type that implements this trait as children to the HTML wrapper.

    Currently it accepts the following types:

    typeexample
    Array[Html]div([html1, html2])
    Stringdiv("string here")
    Htmldiv(p([...]))
    Map[String,Html]div({"k1": html1, "k2": html2})

    #Keyed Children

    When children are passed as Map[String, Html], Rabbita treats them as keyed children. Keys are used to match and reuse nodes across updates, which helps preserve DOM and Cell state when items are inserted, removed, or reordered.

    • Keys must be unique and stable (use a business ID, not an array index).
    • Changing a key means the old node is removed and a new one is created.

    Example:

    ///|
    let html : Html = ul({
    "todo-1": li("Buy milk"),
    "todo-2": li("Write docs"),
    "todo-3": li("Write code"),
    })

    #Event Handlers

    Rabbita separates event callbacks from UI views to manage side effects and avoid stale state, keeping UI predictable as code grows.

    HTML wrappers provide common events as optional arguments like on_click, on_mouseup, on_scroll, and on_submit. Each requires a Cmd binding to a Msg you define. When an event fires, the Msg (and any extra payload) is forwarded to the centralized state update function.

    Registering the same event more than once composes the handlers in registration order. When a wrapper receives both an event in attrs and its matching named event argument, the attrs handler runs first and the named handler runs second. Non-event attributes and properties keep their usual last-write-wins behavior.

    Example:

    ///|
    #cfg(target="js")
    fn update2(msg : Msg2, _ : Model2) -> Model2 {
    match msg {
    StartDraw(mouse) => println("start at \{mouse.offset_pos()}")
    EndDraw(mouse) => println("end at \{mouse.offset_pos()}")
    }
    }

    ///|
    fn view2(emit : Emit[Msg2], _ : Model2) -> Html {
    canvas(
    on_mousedown=m => emit(StartDraw(m)),
    on_mouseup=m => emit(EndDraw(m)),
    nothing,
    )
    }

    #Advanced Usage

    #Attribute Builder

    The attribute builder is a workaround for cases where the HTML wrapper does not expose a specific attribute or event. It is not the primary API and may be less ergonomic or less type-safe than the dedicated wrapper parameters. Prefer the wrapper options when available, and fall back to the builder only when needed.

    Example:

    ///|
    let html1 : Html = div(
    attrs=Attrs::build().class("card").styles(@style.Style::new().gap(12)).data("..."),
    [text("Hello")],
    )

    #Escape Hatch

    The wrapper functions and properties provided here may not cover all possible use cases. If you encounter missing functionality, feel free to file an issue or use the node() function as a workaround. The node() function allows you to manually specify the tag name, attributes, and children for your HTML element, offering flexibility for advanced or uncommon scenarios.

    ///|
    let html2 : Html = node(
    "div",
    Attrs::build().class("card").styles(@style.Style::new().gap(12)).data("..."),
    [p("text1"), p("text2")],
    )

    Attrs

    type Attrs

    Attrs::abbr

    fn Attrs::abbr(self : Attrs, value : String) -> Attrs

    Attrs::accept

    fn Attrs::accept(self : Attrs, value : String) -> Attrs

    Attrs::accept_charset

    fn Attrs::accept_charset(self : Attrs, value : String) -> Attrs

    Attrs::accesskey

    fn Attrs::accesskey(self : Attrs, value : String) -> Attrs

    Attrs::action

    fn Attrs::action(self : Attrs, value : String) -> Attrs

    Attrs::align

    fn Attrs::align(self : Attrs, value : String) -> Attrs

    Attrs::allow

    fn Attrs::allow(self : Attrs, value : String) -> Attrs

    Attrs::allowfullscreen

    fn Attrs::allowfullscreen(self : Attrs, value : Bool) -> Attrs

    Attrs::alpha

    fn Attrs::alpha(self : Attrs, value : String) -> Attrs

    Attrs::alt

    fn Attrs::alt(self : Attrs, value : String) -> Attrs

    Attrs::anchor

    fn Attrs::anchor(self : Attrs, value : String) -> Attrs

    Attrs::aria_activedescendant

    fn Attrs::aria_activedescendant(self : Attrs, value : String) -> Attrs

    Attrs::aria_atomic

    fn Attrs::aria_atomic(self : Attrs, value : String) -> Attrs

    Attrs::aria_autocomplete

    fn Attrs::aria_autocomplete(self : Attrs, value : String) -> Attrs

    Attrs::aria_braillelabel

    fn Attrs::aria_braillelabel(self : Attrs, value : String) -> Attrs

    Attrs::aria_brailleroledescription

    fn Attrs::aria_brailleroledescription(self : Attrs, value : String) -> Attrs

    Attrs::aria_busy

    fn Attrs::aria_busy(self : Attrs, value : String) -> Attrs

    Attrs::aria_checked

    fn Attrs::aria_checked(self : Attrs, value : String) -> Attrs

    Attrs::aria_colcount

    fn Attrs::aria_colcount(self : Attrs, value : String) -> Attrs

    Attrs::aria_colindex

    fn Attrs::aria_colindex(self : Attrs, value : String) -> Attrs

    Attrs::aria_colindextext

    fn Attrs::aria_colindextext(self : Attrs, value : String) -> Attrs

    Attrs::aria_colspan

    fn Attrs::aria_colspan(self : Attrs, value : String) -> Attrs

    Attrs::aria_controls

    fn Attrs::aria_controls(self : Attrs, value : String) -> Attrs

    Attrs::aria_current

    fn Attrs::aria_current(self : Attrs, value : String) -> Attrs

    Attrs::aria_describedby

    fn Attrs::aria_describedby(self : Attrs, value : String) -> Attrs

    Attrs::aria_description

    fn Attrs::aria_description(self : Attrs, value : String) -> Attrs

    Attrs::aria_details

    fn Attrs::aria_details(self : Attrs, value : String) -> Attrs

    Attrs::aria_disabled

    fn Attrs::aria_disabled(self : Attrs, value : String) -> Attrs

    Attrs::aria_dropeffect

    fn Attrs::aria_dropeffect(self : Attrs, value : String) -> Attrs

    Attrs::aria_errormessage

    fn Attrs::aria_errormessage(self : Attrs, value : String) -> Attrs

    Attrs::aria_expanded

    fn Attrs::aria_expanded(self : Attrs, value : String) -> Attrs

    Attrs::aria_flowto

    fn Attrs::aria_flowto(self : Attrs, value : String) -> Attrs

    Attrs::aria_grabbed

    fn Attrs::aria_grabbed(self : Attrs, value : String) -> Attrs

    Attrs::aria_haspopup

    fn Attrs::aria_haspopup(self : Attrs, value : String) -> Attrs

    Attrs::aria_hidden

    fn Attrs::aria_hidden(self : Attrs, value : String) -> Attrs

    Attrs::aria_invalid

    fn Attrs::aria_invalid(self : Attrs, value : String) -> Attrs

    Attrs::aria_keyshortcuts

    fn Attrs::aria_keyshortcuts(self : Attrs, value : String) -> Attrs

    Attrs::aria_label

    fn Attrs::aria_label(self : Attrs, value : String) -> Attrs

    Attrs::aria_labelledby

    fn Attrs::aria_labelledby(self : Attrs, value : String) -> Attrs

    Attrs::aria_level

    fn Attrs::aria_level(self : Attrs, value : String) -> Attrs

    Attrs::aria_live

    fn Attrs::aria_live(self : Attrs, value : String) -> Attrs

    Attrs::aria_modal

    fn Attrs::aria_modal(self : Attrs, value : String) -> Attrs

    Attrs::aria_multiline

    fn Attrs::aria_multiline(self : Attrs, value : String) -> Attrs

    Attrs::aria_multiselectable

    fn Attrs::aria_multiselectable(self : Attrs, value : String) -> Attrs

    Attrs::aria_orientation

    fn Attrs::aria_orientation(self : Attrs, value : String) -> Attrs

    Attrs::aria_owns

    fn Attrs::aria_owns(self : Attrs, value : String) -> Attrs

    Attrs::aria_placeholder

    fn Attrs::aria_placeholder(self : Attrs, value : String) -> Attrs

    Attrs::aria_posinset

    fn Attrs::aria_posinset(self : Attrs, value : String) -> Attrs

    Attrs::aria_pressed

    fn Attrs::aria_pressed(self : Attrs, value : String) -> Attrs

    Attrs::aria_readonly

    fn Attrs::aria_readonly(self : Attrs, value : String) -> Attrs

    Attrs::aria_relevant

    fn Attrs::aria_relevant(self : Attrs, value : String) -> Attrs

    Attrs::aria_required

    fn Attrs::aria_required(self : Attrs, value : String) -> Attrs

    Attrs::aria_roledescription

    fn Attrs::aria_roledescription(self : Attrs, value : String) -> Attrs

    Attrs::aria_rowcount

    fn Attrs::aria_rowcount(self : Attrs, value : String) -> Attrs

    Attrs::aria_rowindex

    fn Attrs::aria_rowindex(self : Attrs, value : String) -> Attrs

    Attrs::aria_rowindextext

    fn Attrs::aria_rowindextext(self : Attrs, value : String) -> Attrs

    Attrs::aria_rowspan

    fn Attrs::aria_rowspan(self : Attrs, value : String) -> Attrs

    Attrs::aria_selected

    fn Attrs::aria_selected(self : Attrs, value : String) -> Attrs

    Attrs::aria_setsize

    fn Attrs::aria_setsize(self : Attrs, value : String) -> Attrs

    Attrs::aria_sort

    fn Attrs::aria_sort(self : Attrs, value : String) -> Attrs

    Attrs::aria_valuemax

    fn Attrs::aria_valuemax(self : Attrs, value : String) -> Attrs

    Attrs::aria_valuemin

    fn Attrs::aria_valuemin(self : Attrs, value : String) -> Attrs

    Attrs::aria_valuenow

    fn Attrs::aria_valuenow(self : Attrs, value : String) -> Attrs

    Attrs::aria_valuetext

    fn Attrs::aria_valuetext(self : Attrs, value : String) -> Attrs

    Attrs::as_

    fn Attrs::as_(self : Attrs, value : String) -> Attrs

    Attrs::async_

    fn Attrs::async_(self : Attrs, value : Bool) -> Attrs

    Attrs::autocapitalize

    fn Attrs::autocapitalize(self : Attrs, value : String) -> Attrs

    Attrs::autocomplete

    fn Attrs::autocomplete(self : Attrs, value : AutoComplete) -> Attrs

    Attrs::autocorrect

    fn Attrs::autocorrect(self : Attrs, value : String) -> Attrs

    Attrs::autofocus

    fn Attrs::autofocus(self : Attrs, value : Bool) -> Attrs

    Attrs::autoplay

    fn Attrs::autoplay(self : Attrs, value : Bool) -> Attrs

    Attrs::background

    fn Attrs::background(self : Attrs, value : String) -> Attrs

    Attrs::bgcolor

    fn Attrs::bgcolor(self : Attrs, value : String) -> Attrs

    Attrs::border

    fn Attrs::border(self : Attrs, value : Int) -> Attrs

    Attrs::build

    fn Attrs::build() -> Attrs

    Attrs::capture

    fn Attrs::capture(self : Attrs, value : String) -> Attrs

    Attrs::charset

    fn Attrs::charset(self : Attrs, value : String) -> Attrs

    Attrs::checked

    fn Attrs::checked(self : Attrs, value : Bool) -> Attrs

    Attrs::cite

    fn Attrs::cite(self : Attrs, value : String) -> Attrs

    Attrs::class

    fn Attrs::class(self : Attrs, value : String) -> Attrs

    Attrs::closedby

    fn Attrs::closedby(self : Attrs, value : String) -> Attrs

    Set the dialog closedby attribute.

    Browser support is limited. Rabbita only emits the attribute; it does not polyfill dismissal behavior. Values include "none", "closerequest", and "any". MDN

    Attrs::color

    fn Attrs::color(self : Attrs, value : String) -> Attrs

    Attrs::colorspace

    fn Attrs::colorspace(self : Attrs, value : String) -> Attrs

    Attrs::cols

    fn Attrs::cols(self : Attrs, value : Int) -> Attrs

    Attrs::colspan

    fn Attrs::colspan(self : Attrs, value : Int) -> Attrs

    Attrs::content

    fn Attrs::content(self : Attrs, value : String) -> Attrs

    Attrs::contenteditable

    fn Attrs::contenteditable(self : Attrs, value : String) -> Attrs

    Attrs::controls

    fn Attrs::controls(self : Attrs, value : Bool) -> Attrs

    Attrs::coords

    fn Attrs::coords(self : Attrs, value : String) -> Attrs

    Attrs::copy

    fn Attrs::copy(self : Attrs) -> Attrs

    Return an independent copy that can be extended without mutating self.

    Attrs::crossorigin

    fn Attrs::crossorigin(self : Attrs, value : String) -> Attrs

    Attrs::csp

    fn Attrs::csp(self : Attrs, value : String) -> Attrs

    Attrs::data

    fn Attrs::data(self : Attrs, value : String) -> Attrs

    Attrs::data_set

    fn Attrs::data_set(self : Attrs, name : String, value : String) -> Attrs

    Attrs::datetime

    fn Attrs::datetime(self : Attrs, value : String) -> Attrs

    Attrs::decoding

    fn Attrs::decoding(self : Attrs, value : String) -> Attrs

    Attrs::default

    fn Attrs::default(self : Attrs, value : Bool) -> Attrs

    Attrs::defer_

    fn Attrs::defer_(self : Attrs, value : Bool) -> Attrs

    Attrs::dir

    fn Attrs::dir(self : Attrs, value : String) -> Attrs

    Attrs::dirname

    fn Attrs::dirname(self : Attrs, value : String) -> Attrs

    Attrs::disabled

    fn Attrs::disabled(self : Attrs, value : Bool) -> Attrs

    Attrs::download

    fn Attrs::download(self : Attrs, value : String) -> Attrs

    Attrs::draggable

    fn Attrs::draggable(self : Attrs, value : String) -> Attrs

    Attrs::elementtiming

    fn Attrs::elementtiming(self : Attrs, value : String) -> Attrs

    Attrs::enctype

    fn Attrs::enctype(self : Attrs, value : String) -> Attrs

    Attrs::enterkeyhint

    fn Attrs::enterkeyhint(self : Attrs, value : String) -> Attrs

    Attrs::exportparts

    fn Attrs::exportparts(self : Attrs, value : String) -> Attrs

    Attrs::fetchpriority

    fn Attrs::fetchpriority(self : Attrs, value : String) -> Attrs

    Attrs::for_

    fn Attrs::for_(self : Attrs, value : String) -> Attrs

    Attrs::form

    fn Attrs::form(self : Attrs, value : String) -> Attrs

    Attrs::formaction

    fn Attrs::formaction(self : Attrs, value : String) -> Attrs

    Attrs::formenctype

    fn Attrs::formenctype(self : Attrs, value : String) -> Attrs

    Attrs::formmethod

    fn Attrs::formmethod(self : Attrs, value : String) -> Attrs

    Attrs::formnovalidate

    fn Attrs::formnovalidate(self : Attrs, value : Bool) -> Attrs

    Attrs::formtarget

    fn Attrs::formtarget(self : Attrs, value : String) -> Attrs

    Attrs::headers

    fn Attrs::headers(self : Attrs, value : String) -> Attrs

    Attrs::height

    fn Attrs::height(self : Attrs, value : Int) -> Attrs

    Attrs::hidden

    fn Attrs::hidden(self : Attrs, value : Bool) -> Attrs

    Attrs::high

    fn Attrs::high(self : Attrs, value : Int) -> Attrs

    Attrs::href

    fn Attrs::href(self : Attrs, value : String) -> Attrs

    Attrs::hreflang

    fn Attrs::hreflang(self : Attrs, value : String) -> Attrs

    Attrs::http_equiv

    fn Attrs::http_equiv(self : Attrs, value : String) -> Attrs

    Attrs::id

    fn Attrs::id(self : Attrs, value : String) -> Attrs

    Attrs::inert

    fn Attrs::inert(self : Attrs, value : Bool) -> Attrs

    Attrs::inner_html

    #internal(xss_vulnerable, "This function may cause xss attack.")
    fn Attrs::inner_html(self : Attrs, html : String) -> Attrs

    Sets raw HTML and bypasses normal escaping.

    Vulnerability Warning

    This is XSS‑prone and should only be used with trusted or sanitized input. It affects both HTML and SVG content since the browser will parse the string into DOM nodes.

    Attrs::inputmode

    fn Attrs::inputmode(self : Attrs, value : String) -> Attrs

    Attrs::integrity

    fn Attrs::integrity(self : Attrs, value : String) -> Attrs

    Attrs::is_

    fn Attrs::is_(self : Attrs, value : String) -> Attrs

    Attrs::ismap

    fn Attrs::ismap(self : Attrs, value : Bool) -> Attrs

    Attrs::itemid

    fn Attrs::itemid(self : Attrs, value : String) -> Attrs

    Attrs::itemprop

    fn Attrs::itemprop(self : Attrs, value : String) -> Attrs

    Attrs::itemref

    fn Attrs::itemref(self : Attrs, value : String) -> Attrs

    Attrs::itemscope

    fn Attrs::itemscope(self : Attrs, value : Bool) -> Attrs

    Attrs::itemtype

    fn Attrs::itemtype(self : Attrs, value : String) -> Attrs

    Attrs::kind

    fn Attrs::kind(self : Attrs, value : String) -> Attrs

    Attrs::label

    fn Attrs::label(self : Attrs, value : String) -> Attrs

    Attrs::lang

    fn Attrs::lang(self : Attrs, value : String) -> Attrs

    Attrs::language

    fn Attrs::language(self : Attrs, value : String) -> Attrs

    Attrs::list

    fn Attrs::list(self : Attrs, value : String) -> Attrs

    Attrs::loading

    fn Attrs::loading(self : Attrs, value : String) -> Attrs

    Attrs::loop_

    fn Attrs::loop_(self : Attrs, value : Bool) -> Attrs

    Attrs::low

    fn Attrs::low(self : Attrs, value : Int) -> Attrs

    Attrs::max

    fn Attrs::max(self : Attrs, value : Int) -> Attrs

    Attrs::maxlength

    fn Attrs::maxlength(self : Attrs, value : Int) -> Attrs

    Attrs::media

    fn Attrs::media(self : Attrs, value : String) -> Attrs

    Attrs::method_

    fn Attrs::method_(self : Attrs, value : String) -> Attrs

    Attrs::min

    fn Attrs::min(self : Attrs, value : Int) -> Attrs

    Attrs::minlength

    fn Attrs::minlength(self : Attrs, value : Int) -> Attrs

    Attrs::multiple

    fn Attrs::multiple(self : Attrs, value : Bool) -> Attrs

    Attrs::muted

    fn Attrs::muted(self : Attrs, value : Bool) -> Attrs

    Attrs::name

    fn Attrs::name(self : Attrs, value : String) -> Attrs

    Attrs::nonce

    fn Attrs::nonce(self : Attrs, value : String) -> Attrs

    Attrs::novalidate

    fn Attrs::novalidate(self : Attrs, value : Bool) -> Attrs

    Attrs::on_pointercancel

    Handle browser cancellation of an active pointer interaction.

    Attrs::on_pointerdown

    Handle a primary or auxiliary pointer starting contact with the element.

    PointerEvent extends the browser's mouse-event surface, so the callback uses Rabbita's existing MouseEvent wrapper while preserving pointer-only fields for JavaScript FFI helpers.

    Attrs::on_pointermove

    Handle movement from a captured mouse, pen, or touch pointer.

    Attrs::on_pointerup

    Handle the end of a mouse, pen, or touch pointer interaction.

    Attrs::on_raw

    fn Attrs::on_raw(self : Attrs, event : String, msg : (Payload) ->
    Cmd
    ) -> Attrs

    注册一个任意事件键的处理器,载荷原样交给回调。

    与 on_click / on_change 那批的区别:那批的载荷类型是写死的 DOM 类型(于是被透传表填零值), 这里的载荷是 Payload(真实值)。

    @html.node("antd:Input",
    @html.Attrs::build()
    .prop_str("value", model.draft)
    .on_raw("change", e => emit(SetDraft(e.text()))),
    [])

    事件键 → 真正的 prop 名由宿主决定(MOBILE_HOST.events,见 ../../../../render.mbt 的 map_event):change 在 antd 上落 onChange、 在 RN 的 TextInput 上落 onChangeText。

    Attrs::open

    fn Attrs::open(self : Attrs, value : Bool) -> Attrs

    Attrs::optimum

    fn Attrs::optimum(self : Attrs, value : Int) -> Attrs

    Attrs::part

    fn Attrs::part(self : Attrs, value : String) -> Attrs

    Attrs::pattern

    fn Attrs::pattern(self : Attrs, value : String) -> Attrs

    Attrs::ping

    fn Attrs::ping(self : Attrs, value : String) -> Attrs

    Attrs::placeholder

    fn Attrs::placeholder(self : Attrs, value : String) -> Attrs

    Attrs::playsinline

    fn Attrs::playsinline(self : Attrs, value : Bool) -> Attrs

    Attrs::popover

    fn Attrs::popover(self : Attrs, value : String) -> Attrs

    Attrs::poster

    fn Attrs::poster(self : Attrs, value : String) -> Attrs

    Attrs::preload

    fn Attrs::preload(self : Attrs, value : String) -> Attrs

    Attrs::prop_bool

    fn Attrs::prop_bool(self : Attrs, key : String, value : Bool) -> Attrs

    见 Attrs::prop_str。布尔 prop —— React 组件库里最常见的形态 (danger / loading / block / hoverable)。

    Attrs::prop_int

    fn Attrs::prop_int(self : Attrs, key : String, value : Int) -> Attrs

    见 Attrs::prop_str。整数 prop(RN 的 numberOfLines、枚举下标)。

    Attrs::prop_json

    fn Attrs::prop_json(self : Attrs, key : String, value : String) -> Attrs

    见 Attrs::prop_str。结构化 prop:值是 JSON 文本,由宿主适配器 JSON.parse 之后交给组件库。

    与 prop_str 在表示上完全相同(边界上都是一段字符串),分开命名是为了 在调用点就把"这个键会被解析"写清楚 —— 否则 columns="[{…}]" 在 MoonBit 侧 看起来只是个普通字符串,而它的合法性(是不是合法 JSON、schema 对不对) 编译期无从检查,只能由宿主侧兜(这也是它必须被 jsonProps 白名单约束的原因)。

    Attrs::prop_num

    fn Attrs::prop_num(self : Attrs, key : String, value : Double) -> Attrs

    见 Attrs::prop_str。浮点 prop(尺寸、比例)。

    Attrs::prop_str

    fn Attrs::prop_str(self : Attrs, key : String, value : String) -> Attrs

    ★ moobile 扩展:通往任意 prop 的公开通道。

    为什么必须有它:这个包的公开面是几百个按 HTML 属性命名的方法 (accept / disabled / title …),它们覆盖得住 HTML,覆盖不住 React 组件库的 props —— danger、loading、block、columns、dataSource 这些名字在 HTML 里根本不存在,于是外面写 antd:Button 时一个属性都传不进去。 而 attribute / property 两个通用入口此前是包内私有的 (Attrs(Props) 的字段也不对外,所以别的包绕不过去自己拼一个)。

    设计取舍:
    • 只开"写"的口,不开"读"的口 —— 外部仍然只能通过 Attrs 构造属性, 不引入第二个 Props 构造路径(to_props 依旧私有);
    • 不引入新的值类型 —— 值域就是 vdom 已有的 4 个 Variant 构造器, 于是 render.mbt 不必改,RN 与 DOM 两个后端的行为也天然一致;
    • 结构化数据(对象 / 数组)不在值域里,走 prop_json 的字符串约定 (解析由宿主侧的库适配器负责,见 npm/moobile-host 的 jsonProps)。

    与 Attrs::attribute 的关系:在 React 后端里两者产出完全一样 (都是 props 上的一个键),区别只在 rabbita 自己的 DOM 后端 (属性 vs property 的 diff 语义)。所以这里统一走 property。

    Attrs::readonly_

    fn Attrs::readonly_(self : Attrs, value : Bool) -> Attrs

    Attrs::referrerpolicy

    fn Attrs::referrerpolicy(self : Attrs, value : String) -> Attrs

    Attrs::rel

    fn Attrs::rel(self : Attrs, value : String) -> Attrs

    Attrs::required

    fn Attrs::required(self : Attrs, value : Bool) -> Attrs

    Attrs::reversed

    fn Attrs::reversed(self : Attrs, value : Bool) -> Attrs

    Attrs::role

    fn Attrs::role(self : Attrs, value : String) -> Attrs

    Attrs::rows

    fn Attrs::rows(self : Attrs, value : Int) -> Attrs

    Attrs::rowspan

    fn Attrs::rowspan(self : Attrs, value : Int) -> Attrs

    Attrs::sandbox

    fn Attrs::sandbox(self : Attrs, value : String) -> Attrs

    Attrs::scope

    fn Attrs::scope(self : Attrs, value : Scope) -> Attrs

    Attrs::selected

    fn Attrs::selected(self : Attrs, value : Bool) -> Attrs

    Attrs::shape

    fn Attrs::shape(self : Attrs, value : String) -> Attrs

    Attrs::size

    fn Attrs::size(self : Attrs, value : Int) -> Attrs

    Attrs::sizes

    fn Attrs::sizes(self : Attrs, value : String) -> Attrs

    Attrs::slot

    fn Attrs::slot(self : Attrs, value : String) -> Attrs

    Attrs::span

    fn Attrs::span(self : Attrs, value : Int) -> Attrs

    Attrs::spellcheck

    fn Attrs::spellcheck(self : Attrs, value : Bool) -> Attrs

    Attrs::src

    fn Attrs::src(self : Attrs, value : String) -> Attrs

    Attrs::srcdoc

    fn Attrs::srcdoc(self : Attrs, value : String) -> Attrs

    Attrs::srclang

    fn Attrs::srclang(self : Attrs, value : String) -> Attrs

    Attrs::srcset

    fn Attrs::srcset(self : Attrs, value : String) -> Attrs

    Attrs::start

    fn Attrs::start(self : Attrs, value : Int) -> Attrs

    Attrs::step

    fn Attrs::step(self : Attrs, value : Int) -> Attrs

    Attrs::style_attr

    fn Attrs::style_attr(self : Attrs, value : String) -> Attrs

    Attrs::styles

    合并一份类型化样式 —— 这是唯一的结构化样式入口。

    ★ moobile 改造:原来的 Attrs::style(key : String, value : String) 已删除。 理由有两条,都有实测支撑:

    1. 字符串通道让 fontWeight(RN 要字符串)与 fontSize(RN 要数字) 在编译期无法区分,只能靠运行时白名单兜(见 README 的 F3)。
    2. 它零调用点 —— 唯一真实应用 interest/yi 从未用过结构化样式 (136 处 class= / 0 处 style=),所以删掉不破坏任何代码。

    Attrs::summary

    fn Attrs::summary(self : Attrs, value : String) -> Attrs

    Attrs::tabindex

    fn Attrs::tabindex(self : Attrs, value : Int) -> Attrs

    Attrs::target

    fn Attrs::target(self : Attrs, value : Target) -> Attrs

    Attrs::title

    fn Attrs::title(self : Attrs, value : String) -> Attrs

    Attrs::translate

    fn Attrs::translate(self : Attrs, value : String) -> Attrs

    Attrs::type_

    fn Attrs::type_(self : Attrs, value : String) -> Attrs

    Attrs::usemap

    fn Attrs::usemap(self : Attrs, value : String) -> Attrs

    Attrs::value

    fn Attrs::value(self : Attrs, value : String) -> Attrs

    Attrs::value_int

    fn Attrs::value_int(self : Attrs, value : Int) -> Attrs

    Attrs::value_prop

    fn Attrs::value_prop(self : Attrs, value : String) -> Attrs

    Attrs::width

    fn Attrs::width(self : Attrs, value : Int) -> Attrs

    Attrs::wrap

    fn Attrs::wrap(self : Attrs, value : String) -> Attrs

    AutoComplete

    pub(all) enum AutoComplete {
    On
    Off
    }

    EventDecoders

    pub struct EventDecoders {
    mouse_event : (
    Event
    ) ->
    MouseEvent

    keyboard_event : (
    Event
    ) ->
    KeyboardEvent

    focus_event : (
    Event
    ) ->
    FocusEvent

    drag_event : (
    Event
    ) ->
    DragEvent

    clipboard_event : (
    Event
    ) ->
    ClipboardEvent

    composition_event : (
    Event
    ) ->
    CompositionEvent

    wheel_event : (
    Event
    ) ->
    WheelEvent

    ui_event : (
    Event
    ) ->
    UIEvent

    input_event : (
    Event
    ) ->
    InputEvent

    dom_event : (
    Event
    ) ->
    Event

    mouse : (
    MouseEvent
    ) ->
    Mouse

    keyboard : (
    KeyboardEvent
    ) ->
    Keyboard

    scroll : (
    UIEvent
    ) ->
    Scroll

    }

    各事件载荷的解码策略表 —— 这是 moobile 对 rabbita 的第三批实质改造。

    为什么必须做

    rabbita 原本把 DOM 语义写死在每个 on_* 处理器里:

    scheduler.add(msg(raw.to_keyboard_event().unwrap()))

    这在浏览器里成立,但 unwrap() 在任何非浏览器宿主上都会 panic。 第一次踩到的是 on_mouse_event:React Native 的 Pressable 给的是合成 press 事件,to_mouse_event() 返回 None → 点一下就崩。

    普查(_r1/dom_survey.txt)发现这不是孤例:html/ + svg/ 里共 45 处 @dom.,其中同一形状的 panic 有 13 个(下表每一栏一个)。 只修 mouse 那一处,等于把同样的雷留给 keyboard / drag / scroll / input … —— 而 yi 的罗盘拖拽(on_mousedown/move/up 读 Mouse 坐标)正好踩在里面。

    设计

    一张表、一处替换点。DOM 后端保持原样(走浏览器的事件子类型判定), React 后端整表换成"原样透传"。

    目标要说清楚:这里换来的是"不崩、可降级", 不是"载荷也等价"。真正读取载荷的处理器(罗盘拖拽读坐标) 在 RN 上仍拿不到有意义的值 —— 那是设计文档的 R2,需要接手势系统。

    Html

    #alias(T)
    pub(all) struct Html(
    VNode
    ) derive(Eq)

    An HTML value produced by the constructors in this package.

    Html::from_vnode

    Html::to_virtual_dom

    InputType

    pub(all) enum InputType {
    Button
    Checkbox
    Color
    Date
    DateTimeLocal
    Email
    File
    Hidden
    Image
    Month
    Number
    Password
    Radio
    Range
    Reset
    Search
    Submit
    Tel
    Text
    Time
    Url
    Week
    }

    Payload

    ★ moobile 扩展:事件载荷通道(PLAN.md 的 I1;设计见 docs/design/DESIGN-COMPONENT-LIBRARY.md §5 T1)。

    ⚠️ 本文件在 moon.pkg 里被限定为 js 目标(与 event_decoders.mbt 同款): 它的全部实现都建立在"载荷是宿主递过来的 JS 值"之上,其它目标上不存在这个前提。

    为什么需要它

    这个包原有的处理器签名是DOM 味的:on_change : (InputEvent) -> Cmd。 在 React 后端下那些载荷由 event_decoders.mbt 的透传表填充 —— 换来的是"不崩、可降级",代价是读不到值:onChange 会触发,但用户输入的内容拿不到, 于是 Input / Select 这些受控组件用不了("能画、能点,不能用")。

    设计取舍

    1. 不碰旧的 on_* 签名:它们是对 DOM 的承诺,改了会波及 svg/、所有标签助手与既有应用。 这里新增一条平行的通道:Attrs::on_raw(event, f : (Payload) -> Cmd)。
    2. 载荷是不透明的:Payload 只提供少数提取器(text / json / num / bool / field), 而不是把某个后端的类型泄漏出去 —— 因为同一个回调在 DOM 上给的是事件对象、 在 RN 上给的可能直接就是字符串(onChangeText)、在组件库里给的是业务值。 提取器把这三种形态都覆盖掉,于是同一份视图代码两端可用。
    3. 提取器永不抛错:形状对不上时给 "" / 0 / false。 理由:载荷形状是运行时才知道的事(还取决于宿主与组件库的版本), 让它把界面崩掉,等于把"库版本不匹配"变成"白屏"。

    ⚠️ 已知限制(写清楚,不假装完整):回调只取第一个参数 —— 处理器在 vdom 侧的形态是 (v) => f(v),所以 antd onChange(value, option) 这类 多参数回调这里只拿得到第一个。需要更多参数时,在宿主侧用适配器把它们拼成一个值。

    Payload::bool

    fn Payload::bool(self : Payload) -> Bool

    见 Payload::text。

    Payload::field

    fn Payload::field(self : Payload, name : String) -> Payload

    见 Payload::text。

    Payload::json

    fn Payload::json(self : Payload) -> String

    见 Payload::text。

    Payload::num

    fn Payload::num(self : Payload) -> Double

    见 Payload::text。

    Payload::text

    fn Payload::text(self : Payload) -> String

    见 Payload::text。

    Scope

    pub(all) enum Scope {
    Row
    Col
    RowGroup
    ColGroup
    }

    Target

    pub(all) enum Target {
    Self
    Blank
    }

    fn[C : IsChildren] a(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, href~ : String, target? : Target, rel? : String, download? : String, attrs? : Attrs, children : C, escape? : Bool) -> Html

    MDN Create a element.

    Parameters

    • escape: an optional boolean that determines whether the link should be escaped. By default, it is set to false.

      When escape is set to true, clicking the escaped link will cause the browser to immediately navigate to the href target, bypassing any interception logic. As a result, the UrlRequest message will not be triggered.

    • target: an optional Target that specifies where to open the link.

    If the user holds the ctrl key (or the command key on macOS) while clicking the link, the click event will be handled by the browser, and the UrlRequest will not be triggered either.

    If App::with_route(url_request=...) is not configured, browser native navigation is used as well.

    abbr

    fn[C : IsChildren] abbr(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    address

    fn[C : IsChildren] address(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    area

    fn area(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, alt? : String, coords? : String, shape? : String, href? : String, target? : String, attrs? : Attrs) -> Html

    article

    fn[C : IsChildren] article(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    aside

    fn[C : IsChildren] aside(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    audio

    fn[C : IsChildren] audio(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, src? : String, controls? : Bool, autoplay? : Bool, loop_? : Bool, muted? : Bool, preload? : String, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] b(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    base

    fn base(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, href? : String, target? : String, attrs? : Attrs) -> Html

    bdi

    fn[C : IsChildren] bdi(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    bdo

    fn[C : IsChildren] bdo(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    blockquote

    fn[C : IsChildren] blockquote(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn br(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs) -> Html

    button

    fn[C : IsChildren] button(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, type_? : String, disabled? : Bool, name? : String, value? : String, autofocus? : Bool, on_click? :
    Cmd
    , attrs? : Attrs, children : C) -> Html

    caption

    fn[C : IsChildren] caption(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    cite

    fn[C : IsChildren] cite(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    code

    fn[C : IsChildren] code(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    col

    fn col(style? : Array[String], id? : String, span? : Int, class? : String, title? : String, hidden? : Bool, attrs? : Attrs) -> Html

    colgroup

    fn[C : IsChildren] colgroup(style? : Array[String], id? : String, span? : Int, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    data

    fn[C : IsChildren] data(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    datalist

    fn[C : IsChildren] datalist(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] dd(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    del

    fn[C : IsChildren] del(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    details

    fn[C : IsChildren] details(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, open? : Bool, attrs? : Attrs, children : C) -> Html

    dfn

    fn[C : IsChildren] dfn(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    dialog

    fn[C : IsChildren] dialog(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, open? : Bool, closedby? : String, on_close? :
    Emit
    [String], on_cancel? :
    Cmd
    , attrs? : Attrs, children : C) -> Html

    MDN Dialog element.

    Hint: You can use the show and close commands in the @dialog package to manipulate the dialog.

    Attributes

    • open: indicates whether the dialog is open or closed by default.

    • closedby: emits the limited-support browser closedby attribute. Rabbita does not polyfill dismissal behavior.

    Messages

    • close: triggered when the dialog is closed.

      The string payload of the close message is the return value of the dialog.

    • cancel: triggered when the user instructs the browser that they wish to dismiss the current open dialog.

      It can be triggered when the user presses esc or uses the request_close command.

      If the cancel argument is provided, the dialog will not close automatically after this message is triggered. You can use the @dialog.close command to close it or @cmd.none to keep it open.

    Example

    typealias Model = String

    enum Msg {
    Open
    Closed(String)
    YesNo(Bool)
    }

    fn update(msg : Msg, model : Model) -> (Cmd[Msg], Model) {
    match msg {
    Open => (@dialog.show("confirm"), model)
    YesNo(answer) => (@dialog.close("confirm", return_value=answer.to_string()), model)
    Closed(value) => (none(), value)
    }
    }

    fn view(model : Model) -> Html {
    div([
    h1([text(model)]),
    button(on_click=Msg::Open, [text("open")]),
    dialog(id="confirm", on_close=Msg::Closed, [
    p([text("Are you sure?")]),
    button(on_click=YesNo(true), [text("Yes")]),
    button(on_click=YesNo(false), [text("No")]),
    ]),
    ])
    }

    fn[C : IsChildren] dl(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    dom_decoders

    fn dom_decoders() -> EventDecoders

    DOM 默认实现:走浏览器的事件子类型判定。行为与原实现逐字一致。
    fn[C : IsChildren] dt(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] em(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    embed

    fn embed(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs) -> Html

    event_decoders

    全局解码表。后端启动时替换(React 后端见 moobile/app.mbt)。

    fencedframe

    fn fencedframe(style? : Array[String], id? : String, class? : String, hidden? : Bool, src? : String, title? : String, width? : Int, height? : Int, loading? : String, allow? : String, sandbox? : String, allowfullscreen? : Bool, attrs? : Attrs) -> Html

    fieldset

    fn[C : IsChildren] fieldset(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, disabled? : Bool, name? : String, attrs? : Attrs, children : C) -> Html

    figcaption

    fn[C : IsChildren] figcaption(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    figure

    fn[C : IsChildren] figure(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] footer(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    form

    fn[C : IsChildren] form(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, action? : String, name? : String, on_submit? :
    Cmd
    , attrs? : Attrs, children : C) -> Html

    on_submit will call prevent_default() before dispatching the command. If you need the browser default behavior, use attrs with Attrs::on_submit.

    form_value_from_event

    ★ moobile 扩展:从"输入事件"里取表单值的可替换策略。

    为什么需要它:rabbita 原本把 DOM 语义写死了 —— 从事件对象上 event.currentTarget / event.target 再 .value 取值。 但 React Native 的 TextInput 回调(onChangeText)直接给字符串, 压根不存在 DOM 事件对象。于是这一步必须可替换: DOM 后端保持原样,React 后端把它换成"事件槽位里装的就是文本"。

    换掉这一个函数,on_input=emit.map(SetDraft) 就能在 RN 上原样工作 —— 也就是 yi 那种视图代码不需要改。这是 fork 换来的第二处实质收益。

    ★ 参数类型是后端无关的 Event(不再是 @dom.Event)—— DOM 实现自己负责在内部转回 @dom.Event。

    fragment

    fn fragment(children : Array[Html]) -> Html

    geolocation

    fn[C : IsChildren] geolocation(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] h1(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, cite? : String, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] h2(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] h3(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] h4(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] h5(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] h6(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] head(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] header(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    hgroup

    fn[C : IsChildren] hgroup(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn hr(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs) -> Html

    html

    fn html(style? : Array[String], id? : String, class? : String, title? : String, lang? : String, dir? : String, hidden? : Bool, attrs? : Attrs, children : Array[Html]) -> Html

    Constructs the root of an HTML document.

    Use this constructor only with exactly one head followed by exactly one body:

    html(...) [
    head(...),
    body(...),
    ]

    This restriction follows the Web platform's special handling of document roots: while parsing HTML, browsers may supply missing <html>, <head>, and <body> elements. Rabbita therefore leaves any other child count, order, tag, or nesting undefined.

    For the Web behavior behind this restriction, see MDN: DOMParser.parseFromString().
    fn[C : IsChildren] i(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    iframe

    fn iframe(style? : Array[String], id? : String, class? : String, hidden? : Bool, src? : String, title? : String, width? : Int, height? : Int, loading? : String, allow? : String, sandbox? : String, allowfullscreen? : Bool, attrs? : Attrs) -> Html

    img

    fn img(style? : Array[String], id? : String, class? : String, hidden? : Bool, src? : String, alt? : String, title? : String, width? : Int, height? : Int, srcset? : String, sizes? : String, loading? : String, decoding? : String, attrs? : Attrs) -> Html

    input

    fn input(input_type? : InputType, name? : String, value? : String, checked? : Bool, read_only? : Bool, multiple? : Bool, accept? : String, placeholder? : String, auto_complete? : AutoComplete, style? : Array[String], max? : Int, min? : Int, step? : Int, maxlength? : Int, minlength? : Int, pattern? : String, size? : Int, width? : Int, height? : Int, id? : String, class? : String, title? : String, hidden? : Bool, required? : Bool, autofocus? : Bool, list? : String, inputmode? : String, on_change? :
    Emit
    [String], on_input? :
    Emit
    [String], attrs? : Attrs) -> Html

    ins

    fn[C : IsChildren] ins(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    kbd

    fn[C : IsChildren] kbd(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    label

    fn[C : IsChildren] label(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, for_? : String, attrs? : Attrs, children : C) -> Html

    legend

    fn[C : IsChildren] legend(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] li(style? : Array[String], value? : Int, id? : String, class? : String, title? : String, hidden? : Bool, on_click? :
    Cmd
    , attrs? : Attrs, children : C) -> Html
    fn link(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, href? : String, rel? : String, type_? : String, media? : String, sizes? : String, attrs? : Attrs) -> Html

    main_

    fn[C : IsChildren] main_(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    map

    fn[C : IsChildren] map(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, name? : String, attrs? : Attrs, children : C) -> Html

    mark

    fn[C : IsChildren] mark(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    math

    fn[C : IsChildren] math(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] menu(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    meta

    fn meta(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, charset? : String, name? : String, content? : String, http_equiv? : String, attrs? : Attrs) -> Html

    meter

    fn[C : IsChildren] meter(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, value? : Int, min? : Int, max? : Int, low? : Int, high? : Int, optimum? : Int, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] nav(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    node

    fn[C : IsChildren] node(tag : String, attrs : Attrs, children : C) -> Html

    noscript

    fn[C : IsChildren] noscript(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    nothing

    let nothing : Html

    Represents an empty element

    object

    fn[C : IsChildren] object(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] ol(style? : Array[String], reversed? : Bool, start? : Int, id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    MDN Notice that the type attribute for ol is not important for the browser now. If you want to change the type of the list, you should use the list-style-type property in CSS.

    optgroup

    fn[C : IsChildren] optgroup(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, label? : String, disabled? : Bool, attrs? : Attrs, children : C) -> Html

    option

    fn[C : IsChildren] option(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, label? : String, disabled? : Bool, value? : String, selected? : Bool, attrs? : Attrs, children : C) -> Html

    output

    fn[C : IsChildren] output(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, name? : String, for_? : String, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] p(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    passthrough_decoders

    fn passthrough_decoders() -> EventDecoders

    透传表:给非 DOM 宿主(React Native)用。

    前十项一律"把递过来的值当作目标类型"—— 因为 RN 的合成事件不是 DOM 子类型, to_xxx_event() 一律返回 None,原来的 unwrap() 必崩(这是实测过的真 bug)。

    后三项(Mouse/Keyboard/Scroll,载荷是 rabbita 自己的类型)返回零值: 没有 DOM 就拿不到坐标、按键与滚动量。 读取这些值的处理器会拿到 0 —— 这是已知降级,不是等价替换。 (设计文档的 R2:要拿到真实手势数据得接 RN 的手势系统。)

    放在 html 里而不是 moobile 里,是因为构造 Mouse/Keyboard/Scroll 与构造结构体字段都需要包内访问权;让本包同时提供两张表代价最小。

    picture

    fn[C : IsChildren] picture(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    pre

    fn[C : IsChildren] pre(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    progress

    fn[C : IsChildren] progress(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, value? : Int, max? : Int, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] q(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] rp(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] rt(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    ruby

    fn[C : IsChildren] ruby(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] s(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    samp

    fn[C : IsChildren] samp(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    script

    fn[C : IsChildren] script(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, src? : String, type_? : String, async_? : Bool, defer_? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] search(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    section

    fn[C : IsChildren] section(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    select

    fn[C : IsChildren] select(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, disabled? : Bool, name? : String, multiple? : Bool, size? : Int, required? : Bool, autofocus? : Bool, on_change? :
    Emit
    [String], attrs? : Attrs, children : C) -> Html

    selectedcontent

    fn[C : IsChildren] selectedcontent(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    slot

    fn[C : IsChildren] slot(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    small

    fn[C : IsChildren] small(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    source

    fn source(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, src? : String, srcset? : String, media? : String, type_? : String, sizes? : String, attrs? : Attrs) -> Html

    span

    fn[C : IsChildren] span(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    strong

    fn[C : IsChildren] strong(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    style_tag

    fn[C : IsChildren] style_tag(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    sub

    fn[C : IsChildren] sub(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    summary

    fn[C : IsChildren] summary(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    sup

    fn[C : IsChildren] sup(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    svg

    fn[C : IsChildren] svg(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    table

    fn[C : IsChildren] table(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    tbody

    fn[C : IsChildren] tbody(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] td(style? : Array[String], id? : String, colspan? : Int, rowspan? : Int, headers? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    template

    fn[C : IsChildren] template(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    text

    fn text(str : String) -> Html

    textarea

    fn[C : IsChildren] textarea(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, name? : String, value? : String, rows? : Int, cols? : Int, placeholder? : String, read_only? : Bool, disabled? : Bool, maxlength? : Int, minlength? : Int, required? : Bool, autofocus? : Bool, wrap? : String, on_change? :
    Emit
    [String], on_input? :
    Emit
    [String], attrs? : Attrs, children : C) -> Html

    tfoot

    fn[C : IsChildren] tfoot(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] th(style? : Array[String], id? : String, abbr? : String, colspan? : Int, rowspan? : Int, headers? : String, scope? : Scope, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    thead

    fn[C : IsChildren] thead(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    time

    fn[C : IsChildren] time(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, datetime? : String, attrs? : Attrs, children : C) -> Html

    title

    fn[C : IsChildren] title(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] tr(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    track

    fn track(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, kind? : String, srclang? : String, label? : String, default? : Bool, src? : String, attrs? : Attrs) -> Html
    fn[C : IsChildren] u(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html
    fn[C : IsChildren] ul(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, on_click? :
    Cmd
    , attrs? : Attrs, children : C) -> Html

    var_

    fn[C : IsChildren] var_(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs, children : C) -> Html

    video

    fn[C : IsChildren] video(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, src? : String, controls? : Bool, autoplay? : Bool, loop_? : Bool, muted? : Bool, preload? : String, poster? : String, attrs? : Attrs, children : C) -> Html

    wbr

    fn wbr(style? : Array[String], id? : String, class? : String, title? : String, hidden? : Bool, attrs? : Attrs) -> Html