I am currently in the process of developing some code that utilizes Element.getBoundingClientRect
(gBCR), combined with inline style updates, to carry out calculations. This particular project is not intended for a general website, so I am not interested in exploring "better CSS methods" for this specific task.
The JavaScript operates synchronously and follows these steps:
- Retrieve the gBCR of the parent element
- Conduct calculations;
- Update inline CSS styles (such as size and margins) of a child element belonging to the parent
- Retrieve the gBCR of the parent element again
Can I be certain that the calculated client bounds will reflect the new bounding rectangle of the parent at step 4?
If not ensured by a specification, are modern browser implementations likely to provide this assurance? If so, what exceptions should I be aware of if it's only "mostly guaranteed"?
No elements are being added to or removed from the DOM, and the elements undergoing modifications are direct children of the parent node; pertinent information to consider.
1"Modern": UIWebView (iOS 6+), WebView (Android 2+), and common versions of Chrome/WebKit, Firefox, IE9+, including their mobile counterparts.