Opened 9 years ago
Closed 9 years ago
#14098 closed defect (fixed)
error of null property in scrollable.js findDisp()
Reported by: | zhangyp | Owned by: | ykami |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | DojoX Mobile | Version: | 1.7.0b1 |
Keywords: | Cc: | [email protected]…, Chris Mitchell, Atsushi Ono | |
Blocked By: | Blocking: |
Description
The user reported null property problem in scrollable.js. I checked the latest nightly code. It does not do checking on parentNode in findDisp(). And it would be easy to provide a fix for that.
Hi,
I just downloaded the rc1 code and while preforming a transition to a dynamic ScrollableView?,
I encountered the following error "Cannot read property 'childNodes' of null".
so after tracing it back, I found that it was caused by the findDisp() found in dojox.mobile.scrollable
where it does not check if domeNode has a parent or not before accessing it's children nodes.
concerning the scenario, it is similar to the case that I addressed earlier with PerformTransition? issue #14082,
but earlier I was dealing with View and SwapView? only.
Anyways after modifying findDisp() code and checking if parent node exists, problem was solved!
Regards,
Change History (3)
comment:1 Changed 9 years ago by
Component: | General → DojoX Mobile |
---|---|
Owner: | set to ykami |
comment:2 Changed 9 years ago by
Cc: | Atsushi Ono added |
---|---|
Milestone: | tbd → 1.7 |
Status: | new → assigned |
Bassel, thanks for posting the sample code to dojo-interest. It looks the problem is about widget instantiation sequence, not about view transitions.
In general, recommendation for dynamic widget creation is to instantiate widgets 'on-line', I mean while dom nodes are connected to somewhere in the document. If you did it 'off-line', I mean 'in the air', something unwanted might happen, because, for example, the browser cannot determine dimension of some nodes.
For example, as shown below, if you create an 'on-line' node first, and then create a view based on that node, the problem would not happen.
Another solution would be to create a view first, and then immediately append its domNode to somewhere, before working with Heading. This should solve the problem too.
All that said, I will add the parent check code for safety. But I recommend you to not rely on this fix. The above examples should be safer and work better.