Skip to content

Commit 9acb3de

Browse files
authored
Merge pull request #120 from rescript-lang/fix-get-attribute
Fix getAttribute return type
2 parents 03eae8b + df58e03 commit 9acb3de

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/DOMAPI/Element.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Returns element's first attribute whose qualified name is qualifiedName, and nul
115115
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Element/getAttribute)
116116
*/
117117
@send
118-
external getAttribute: (T.t, string) => string = "getAttribute"
118+
external getAttribute: (T.t, string) => null<string> = "getAttribute"
119119

120120
/**
121121
Returns the qualified names of all element's attributes. Can contain duplicates.

tests/DOMAPI/Element__test.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/DOMAPI/Element__test.res

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
external myElement: DOMAPI.element = "myElement"
2+
3+
switch myElement->Element.getAttribute("foo") {
4+
| Null.Value(value) => value->Console.log
5+
| Null => "nothing"->Console.log
6+
}

0 commit comments

Comments
 (0)