Skip to content

Commit 9c4fe73

Browse files
committed
Added data and aria stuff.
1 parent 9d93da3 commit 9c4fe73

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/React/DOM.purs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ module React.DOM where
22

33
import React
44

5-
data DOMProps s eff props state =
5+
data DOMProps s dataAttrs ariaAttrs eff props state =
66
Accept String
77
| AccessKey String
88
| Action String
99
| AllowFullScreen String
1010
| AllowTransparency String
1111
| Alt String
12+
| Aria { | ariaAttrs }
1213
| Async String
1314
| AutoComplete String
1415
| AutoFocus String
@@ -25,7 +26,7 @@ module React.DOM where
2526
| ContextMenu String
2627
| Controls String
2728
| CrossOrigin String
28-
| Data String
29+
| Data { | dataAttrs }
2930
| DateTime String
3031
| Defer String
3132
| Dir String
@@ -279,7 +280,18 @@ module React.DOM where
279280
\ var prop = props[i]; \
280281
\ var name = prop.ctor.substring(10); \
281282
\ name = name[0].toLowerCase() + name.substring(1); \
282-
\ result[name] = prop.values[0]; \
283+
\ var val = prop.values[0]; \
284+
\ /* Until React.js handles data and aria like style*/ \
285+
\ /* we have to unload the properties.*/ \
286+
\ if (name === 'data' || name === 'aria') { \
287+
\ for (var subprop in val) { \
288+
\ if (val.hasOwnProperty(subprop)) { \
289+
\ result[name + '-' + subprop] = val[subprop]; \
290+
\ } \
291+
\ } \
292+
\ } else { \
293+
\ result[name] = val; \
294+
\ } \
283295
\ } \
284296
\ return result; \
285297
\ } \
@@ -292,7 +304,7 @@ module React.DOM where
292304
\ } \
293305
\ } \
294306
\ }"
295-
:: forall s eff props state. String -> [DOMProps s eff props state] -> [UI] -> UI
307+
:: forall s dataAttrs ariaAttrs eff props state. String -> [DOMProps s dataAttrs ariaAttrs eff props state] -> [UI] -> UI
296308

297309
foreign import text
298310
"function text(text) { \

0 commit comments

Comments
 (0)