Skip to content

Commit

Permalink
Use 0 as a fallback value instead of -1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Nov 17, 2024
1 parent 0205233 commit 29e0c8d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/source/Dom.mint
Original file line number Diff line number Diff line change
Expand Up @@ -595,23 +595,29 @@ module Dom {
Returns the distance from the outer border of the element (including its
margin) to the left padding edge of the closest positioned ancestor element.
If the element is not in the DOM or not an element is passed (for example
`TextNode`) then the value will be `0`.
if let Just(div) = Document.getElementBySelector("div") {
Dom.offsetLeft(div)
}
*/
fun offsetLeft (element : Dom.Element) : Number {
`#{element}.offsetLeft || -1`
`#{element}.offsetLeft || 0`
}

/*
Returns the distance from the outer border of the element (including its
margin) to the top padding edge of the closest positioned ancestor element.
If the element is not in the DOM or not an element is passed (for example
`TextNode`) then the value will be `0`.
if let Just(div) = Document.getElementBySelector("div") {
Dom.offsetTop(div)
}
*/
fun offsetTop (element : Dom.Element) : Number {
`#{element}.offsetTop || -1`
`#{element}.offsetTop || 0`
}
}

0 comments on commit 29e0c8d

Please sign in to comment.