Commit 54d3af2bbee8fbae58970fb9aef8e9dd170c20a4

Authored by totoro
1 parent 56277af9

add "id" and "data" in HTML input attributes

Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
web/CXM_making_a_web_site.anubis
@@ -753,6 +753,7 @@ public type CoreAttrs: @@ -753,6 +753,7 @@ public type CoreAttrs:
753 public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). 753 public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
754 754
755 public type InputAttrs: 755 public type InputAttrs:
  756 + id (String),
756 class (String), 757 class (String),
757 style (String), 758 style (String),
758 title (String), 759 title (String),
@@ -761,7 +762,9 @@ public type InputAttrs: @@ -761,7 +762,9 @@ public type InputAttrs:
761 accesskey (Word8), 762 accesskey (Word8),
762 tabindex (Int), 763 tabindex (Int),
763 attr (String, String), 764 attr (String, String),
764 - event (HtmlEvents, String). 765 + event (HtmlEvents, String),
  766 + //HTML5
  767 + data (String name, String value).
765 768
766 public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false"). 769 public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
767 770
@@ -3225,6 +3228,8 @@ define String @@ -3225,6 +3228,8 @@ define String
3225 [h . t] then 3228 [h . t] then
3226 with current = if h is 3229 with current = if h is
3227 { 3230 {
  3231 + id(id_name) then
  3232 + " id=\"" + id_name + "\"",
3228 class(class_name) then 3233 class(class_name) then
3229 format_attrs(t, [class_name. classes], styles), 3234 format_attrs(t, [class_name. classes], styles),
3230 style(style_string) then 3235 style(style_string) then
@@ -3251,6 +3256,8 @@ define String @@ -3251,6 +3256,8 @@ define String
3251 3256
3252 event(e, value) then 3257 event(e, value) then
3253 " " + event_name(e) + "=\"" + value + "\"", 3258 " " + event_name(e) + "=\"" + value + "\"",
  3259 + data(name, value) then
  3260 + " data-" + to_lower(name) + "=\"" + value + "\"",
3254 }, 3261 },
3255 current + format_attrs(t, classes, styles) 3262 current + format_attrs(t, classes, styles)
3256 }. 3263 }.