Skip to content

Conversation

@nmfriesen
Copy link
Contributor

This update adds a getBoundingClientRect(node) function to dom-geometry
that will call node.getBoundingClientRect() but if it throws an error
(this can happen in IE when the node is not in the DOM) or an empty
object is returned (this can happen in Edge when the node is not in the
DOM) an object with all values set to 0 will be returned. This will
prevent errors when the node is not in the DOM.

fixes #356

error or returns an empty object

This update adds a getBoundingClientRect(node) function to dom-geometry
that will call node.getBoundingClientRect() but if it throws an error
(this can happen in IE when the node is not in the DOM) or an empty
object is returned (this can happen in Edge when the node is not in the
DOM) an object wil all values set to 0 will be returned. This will
prevent errors when the node is not in the DOM.
@wkeese
Copy link
Member

wkeese commented Jun 3, 2019

This seems like a step backwards, if getBoundingClientRect() fails isn't it better to throw an error than to return a non-sensical value?

@nmfriesen
Copy link
Contributor Author

From what I can tell, FireFox and Chrome currently return { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 } when the node is not on the DOM. I was trying to get the browsers to behave consistently. I leaned towards the option that returned an object in the format that was expected so the calculations that use it could continue without throwing an error.

@wkeese
Copy link
Member

wkeese commented Jun 6, 2019

Hmm, I agree consistency is a good thing.

@dylans
Copy link
Member

dylans commented Sep 4, 2019

As this is a new addition, it will get added for 1.16.0

@dylans dylans merged commit 56b22bb into dojo:master Sep 4, 2019
@dylans dylans added this to the 1.16.0 milestone Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unspecified Error from dom-geometry in IE

3 participants