diff --git a/CHANGELOG.md b/CHANGELOG.md index a8976db..ff788d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,15 @@ ## main + +#### :boom: Breaking Change + +- Corrected return type of `getPropertyValue` for CSS style attributes (it's nullable and now returns an option). + +#### :bug: Bug Fix + +- Widened input type of `Window.getComputedStyle`, allowing subclasses of Element (such as HtmlElement). + # 0.9.1 #### :bug: Bug Fix diff --git a/lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js b/lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js index 7505533..abddaf1 100644 --- a/lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js +++ b/lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js @@ -33,6 +33,10 @@ window.focus(); window.getComputedStyle(el); +window.getComputedStyle(el); + +window.getComputedStyle(el, "hover"); + window.getComputedStyle(el, "hover"); window.getSelection(); @@ -83,7 +87,10 @@ window.onload = (function (param) { console.log("load"); }); +var htmlEl = el; + exports.el = el; +exports.htmlEl = htmlEl; exports.$$event = $$event; exports.handleClick = handleClick; exports.idleId = idleId; diff --git a/src/Webapi/Dom/Webapi__Dom__CssStyleDeclaration.res b/src/Webapi/Dom/Webapi__Dom__CssStyleDeclaration.res index 8a1065a..a9af97a 100644 --- a/src/Webapi/Dom/Webapi__Dom__CssStyleDeclaration.res +++ b/src/Webapi/Dom/Webapi__Dom__CssStyleDeclaration.res @@ -7,7 +7,8 @@ type cssRule /* TODO: Move to Webapi__Dom */ @get external parentRule: t => cssRule = "parentRule" @send external getPropertyPriority: (t, string) => string = "getPropertyPriority" -@send external getPropertyValue: (t, string) => string = "getPropertyValue" +@send @return(nullable) +external getPropertyValue: (t, string) => option = "getPropertyValue" @send external item: (t, int) => string = "item" @send external removeProperty: (t, string) => string = "removeProperty" @send external setProperty: (t, string, string, string) => unit = "setProperty" @@ -135,4 +136,4 @@ type cssRule /* TODO: Move to Webapi__Dom */ @get external widows: t => string = "widows" @get external width: t => string = "width" @get external wordSpacing: t => string = "wordSpacing" -@get external zIndex: t => string = "zIndex" +@get external zIndex: t => string = "zIndex" \ No newline at end of file diff --git a/src/Webapi/Dom/Webapi__Dom__Window.res b/src/Webapi/Dom/Webapi__Dom__Window.res index 5517271..02e510a 100644 --- a/src/Webapi/Dom/Webapi__Dom__Window.res +++ b/src/Webapi/Dom/Webapi__Dom__Window.res @@ -78,11 +78,13 @@ module Impl = ( @send external close: t_window => unit = "close" @send external confirm: (t_window, string) => bool = "confirm" @send external focus: t_window => unit = "focus" - @send external getComputedStyle: (t_window, Dom.element) => Dom.cssStyleDeclaration = "getComputedStyle" + @send + external getComputedStyle: (t_window, Dom.element_like<'a>) => Dom.cssStyleDeclaration = + "getComputedStyle" @send external getComputedStyleWithPseudoElement: ( t_window, - Dom.element, + Dom.element_like<'a>, string, ) => Dom.cssStyleDeclaration = "getComputedStyle" @send @return(nullable) external getSelection: t_window => option = "getSelection" diff --git a/tests/Webapi/Dom/Webapi__Dom__Window__test.res b/tests/Webapi/Dom/Webapi__Dom__Window__test.res index b52f601..8f743bc 100644 --- a/tests/Webapi/Dom/Webapi__Dom__Window__test.res +++ b/tests/Webapi/Dom/Webapi__Dom__Window__test.res @@ -1,6 +1,7 @@ open Webapi.Dom let el = document->Document.createElement("strong") +let htmlEl = el->Element.unsafeAsHtmlElement let event = document->Document.createEvent("my-event") let handleClick = _ => print_endline("asd") @@ -53,7 +54,9 @@ Window.close(window) let _ = window->Window.confirm("is ok?") Window.focus(window) let _ = window->Window.getComputedStyle(el) +let _ = window->Window.getComputedStyle(htmlEl) let _ = window->Window.getComputedStyleWithPseudoElement(el, "hover") +let _ = window->Window.getComputedStyleWithPseudoElement(htmlEl, "hover") let _ = Window.getSelection(window) let _ = window->Window.matchMedia("max-height: 400") let _ = window->Window.moveBy(10, -10)