File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,10 @@ let onIE = Js.to_bool (caml_js_on_ie ())
27
27
28
28
external html_escape : js_string t -> js_string t = " caml_js_html_escape"
29
29
30
- external decode_html_entities : js_string t -> js_string t = " caml_js_html_entities"
30
+ external html_entities : js_string t -> js_string t opt = " caml_js_html_entities"
31
+
32
+ let decode_html_entities s =
33
+ Js.Opt. get (html_entities s) (fun () -> failwith (" Invalid entity " ^ Js. to_string s))
31
34
32
35
class type cssStyleDeclaration = object
33
36
method setProperty :
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ function caml_js_html_escape (s) {
37
37
}
38
38
39
39
//Provides: caml_js_html_entities
40
- //Requires: caml_failwith
41
40
function caml_js_html_entities ( s ) {
42
41
var entity = / ^ & # ? [ 0 - 9 a - z A - Z ] + ; $ /
43
42
if ( s . match ( entity ) )
@@ -49,7 +48,7 @@ function caml_js_html_entities(s) {
49
48
return str ;
50
49
}
51
50
else {
52
- caml_failwith ( "Invalid entity " + s ) ;
51
+ return null ;
53
52
}
54
53
}
55
54
You can’t perform that action at this time.
0 commit comments