#11278 closed defect (fixed)
dojox.mobile.parser reparses the page every time _loadUri completes, breaking widgets
Reported by: | Shane O'Sullivan | Owned by: | Jared Jurkiewicz |
---|---|---|---|
Priority: | high | Milestone: | 1.5 |
Component: | DojoX Mobile | Version: | 1.5.0b3 |
Keywords: | Cc: | James Burke, phiggins, bill, wildbill | |
Blocked By: | Blocking: |
Description (last modified by )
dojox.mobile.parser contains the following code, which is always executed.
dojo._loaders.unshift(function(){
dojox.mobile.parser.parse();
});
When used with the dojox.mobile.app code, each time a new XHR completes, the parse() function is invoked on the entire page. The breaks when it encounters an already instantiated widget, saying that the widget is already loaded.
To those CC'ed, do you have any idea why the lightwieght parser is getting repeatedly called on _loadURI?
Why is this necessary? Can dojo.addOnLoad() not be used so that it is only invoked once? This breaks any mobile app that has more than one templated view, and would be good to get fixed for 1.5
Change History (13)
comment:1 Changed 11 years ago by
Cc: | James Burke phiggins bill wildbill added |
---|---|
Description: | modified (diff) |
comment:2 Changed 11 years ago by
Actually, I have a theory. The template code is trying to call the parser on a template ... and it's passing a params object as the first parameter, not the root node. Or something like that, maybe. I'm not sure. Can you try the following and see if ti makes a difference?
@@ -57,6 +57,9 @@ // The root node in the document to parse from if(!rootNode){ rootNode = dojo.body(); + }else if(!defaultParams && rootNode.rootNode){ + // Case where 'rootNode' is really a params object. + rootNode = rootNode.rootNode; } var nodes = rootNode.getElementsByTagName("*"); var list = [];
comment:3 Changed 11 years ago by
The template code is definitely passing in a root node, and that node is parsed successfully. A second parse is executed by the parser's callback function I described earlier
However, I'll try this solution when I get home to see if it helps. The solution I've found is to just use dojo.addOnLoad() in the parser, rather than directly accessing the dojo._loaders, but perhaps that's not ideal.
comment:4 Changed 11 years ago by
comment:5 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Added the change suggested by jaredj, fixes the issue, closing
comment:6 Changed 11 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This is still an issue. I am going to change the code to use dojo.addOnLoad, which seems to function just the same, but only runs once.
comment:7 Changed 11 years ago by
comment:8 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:9 Changed 11 years ago by
FYI, the weird dojo._loaders.unshift
call, rather than a simple dojo.addOnLoad
call, is so the code to detect whether the machine is in high-contrast mode will run before the parser does.
Presumably that's not an issue for mobile.
comment:10 Changed 11 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
This is still an issue. dojo.addOnload should not be used, as it does not ensure that the parsing is run before all other onload listeners.
comment:11 Changed 11 years ago by
comment:12 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:13 Changed 11 years ago by
Component: | Dojox → DojoX Mobile |
---|
The original author, Yoshiroh Kamiyama, denoted this is how the other parser works, and should be cleared after exec. And he's right. Looking in dojo.parser:
(function(){
})();
So I'm not sure why it is running either.