Opened 12 years ago
Closed 12 years ago
#7808 closed defect (fixed)
A subtle bug in dijit.scrollIntoView()
Reported by: | Eugene Lazutkin | Owned by: | Douglas Hays |
---|---|---|---|
Priority: | high | Milestone: | 1.3 |
Component: | Dijit | Version: | 1.2beta |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
In dijit/_base/scroll.js dijit.scrollIntoView() defines an internal function: addPseudoAttrs(element) (line 28). From the context it is suppose to add some private properties to the "element" parameter. Sometimes it is not the case.
At the very beginning of the function it checks if element.offsetParent is null (line 31). If it is, it changes ... the element to scrollRoot, and goes on modifying the scrollRoot instead. The original element is not modified.
It breaks the loop in line 61:
addPseudoAttrs(parent); var next = parent._parent;
As you can see addPseudoAttrs() didn't modify its parameter (as explained above), yet the code assumes that parent._parent is there. It is not. Nevertheless this is a relatively harmless mistake.
The more serious mistake occurs in the next loop on line 69:
while(element != scrollRoot){ parent = element._parent; if(parent.tagName == "TD"){
Again this code assumes that "element" has "_parent" property set. It doesn't. So the next line blows up the browser.
This effect was observed in the clients code on FF3 and IE7.
Attachments (1)
Change History (4)
Changed 12 years ago by
Attachment: | dijit.scrollInView.pseudo-fix.diff added |
---|
comment:1 Changed 12 years ago by
Milestone: | tbd → future |
---|---|
Owner: | set to Douglas Hays |
Is scrollIntoView being called on a node that is not visible or not added to the DOM? That would be bad. I was unable to recreate the problem using dijit/tests/_base/test_scrollNoDTD.html. Please include a description of the steps to recreate the problem.
comment:2 Changed 12 years ago by
Milestone: | future → 1.3 |
---|---|
Status: | new → assigned |
comment:3 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
My pseudo-fix for the problem: bailing out of the procedure as soon as we detect that something is wrong