Skip to content

Commit 6cd9a71

Browse files
committed
Widened input type of Window.getComputedStyle, allowing subclasses of Element (such as HtmlElement)
1 parent 7851385 commit 6cd9a71

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
- Corrected return type of `getPropertyValue` for CSS style attributes (it's nullable and now returns an option).
1818

19+
#### :bug: Bug Fix
20+
21+
- Widened input type of `Window.getComputedStyle`, allowing subclasses of Element (such as HtmlElement).
22+
1923
# 0.9.1
2024

2125
#### :bug: Bug Fix

lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ window.focus();
3434

3535
window.getComputedStyle(el);
3636

37+
window.getComputedStyle(el);
38+
39+
window.getComputedStyle(el, "hover");
40+
3741
window.getComputedStyle(el, "hover");
3842

3943
window.getSelection();
@@ -85,7 +89,10 @@ window.onload = (function (param) {
8589

8690
});
8791

92+
var htmlEl = el;
93+
8894
exports.el = el;
95+
exports.htmlEl = htmlEl;
8996
exports.$$event = $$event;
9097
exports.handleClick = handleClick;
9198
exports.idleId = idleId;

src/Webapi/Dom/Webapi__Dom__Window.res

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ module Impl = (
7878
@send external close: t_window => unit = "close"
7979
@send external confirm: (t_window, string) => bool = "confirm"
8080
@send external focus: t_window => unit = "focus"
81-
@send external getComputedStyle: (t_window, Dom.element) => Dom.cssStyleDeclaration = "getComputedStyle"
81+
@send
82+
external getComputedStyle: (t_window, Dom.element_like<'a>) => Dom.cssStyleDeclaration =
83+
"getComputedStyle"
8284
@send
8385
external getComputedStyleWithPseudoElement: (
8486
t_window,
85-
Dom.element,
87+
Dom.element_like<'a>,
8688
string,
8789
) => Dom.cssStyleDeclaration = "getComputedStyle"
8890
@send @return(nullable) external getSelection: t_window => option<Dom.selection> = "getSelection"

tests/Webapi/Dom/Webapi__Dom__Window__test.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
open Webapi.Dom
22

33
let el = document->Document.createElement("strong")
4+
let htmlEl = el->Element.unsafeAsHtmlElement
45
let event = document->Document.createEvent("my-event")
56
let handleClick = _ => print_endline("asd")
67

@@ -53,7 +54,9 @@ Window.close(window)
5354
let _ = window->Window.confirm("is ok?")
5455
Window.focus(window)
5556
let _ = window->Window.getComputedStyle(el)
57+
let _ = window->Window.getComputedStyle(htmlEl)
5658
let _ = window->Window.getComputedStyleWithPseudoElement(el, "hover")
59+
let _ = window->Window.getComputedStyleWithPseudoElement(htmlEl, "hover")
5760
let _ = Window.getSelection(window)
5861
let _ = window->Window.matchMedia("max-height: 400")
5962
let _ = window->Window.moveBy(10, -10)

0 commit comments

Comments
 (0)