diff --git a/src/DOMAPI/Element.res b/src/DOMAPI/Element.res index ca92be5..13b665b 100644 --- a/src/DOMAPI/Element.res +++ b/src/DOMAPI/Element.res @@ -115,7 +115,7 @@ Returns element's first attribute whose qualified name is qualifiedName, and nul [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getAttribute) */ @send - external getAttribute: (T.t, string) => string = "getAttribute" + external getAttribute: (T.t, string) => null = "getAttribute" /** Returns the qualified names of all element's attributes. Can contain duplicates. diff --git a/tests/DOMAPI/Element__test.js b/tests/DOMAPI/Element__test.js new file mode 100644 index 0000000..61808ec --- /dev/null +++ b/tests/DOMAPI/Element__test.js @@ -0,0 +1,12 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let value = myElement.getAttribute("foo"); + +if (value === null) { + console.log("nothing"); +} else { + console.log(value); +} + +/* value Not a pure module */ diff --git a/tests/DOMAPI/Element__test.res b/tests/DOMAPI/Element__test.res new file mode 100644 index 0000000..9a766fb --- /dev/null +++ b/tests/DOMAPI/Element__test.res @@ -0,0 +1,6 @@ +external myElement: DOMAPI.element = "myElement" + +switch myElement->Element.getAttribute("foo") { +| Null.Value(value) => value->Console.log +| Null => "nothing"->Console.log +}