Opened 11 years ago

Closed 9 years ago

#11701 closed feature (patchwelcome)

dojo.parser.parse ignores dojoType on the root element; cannot process document fragments

Reported by: MaxMotovilov Owned by: bill
Priority: low Milestone: tbd
Component: Parser Version: 1.5
Keywords: Cc:
Blocked By: Blocking:


As part of the implementation for a new template engine I have to invoke dojo.parser.parse() on an HTML document fragment produced by dojo._toDom() before the fragment is inserted into its final destination within the document. A straightforward approach is hindered by 2 related issues:

1) dojo.parser.parse() cannot accept an HTML document fragment as its first argument, only a single node;

2) it does not properly parse the attributes (i.e. recognize dojoType) on the node itself, only on its descendants, therefore a simple loop over all nodes in the fragment does not help either.

My workaround is to create a temporary "master" node, the fragment into it and parse the master, then let it go out of scope. This is definitely a kludge and a replication of the functionality already existing within dojo._toDom(). It would be nice to either extend the capabilities of dojo.parser.parse() or add an option to dojo._toDom() to automatically invoke the parser on the master before extracting the fragment. And while you're at it, how about making dojo._toDom() a proper user-accessible function?

Change History (2)

comment:1 Changed 10 years ago by bill

Priority: highlow
Type: defectfeature

comment:2 Changed 9 years ago by Kitson Kelly

Resolution: patchwelcome
Status: newclosed

While this maybe a good idea, maybe, it isn't really on the roadmap for the parser at this point in time, although a patch would be welcome.

Note: See TracTickets for help on using tickets.