Opened 7 years ago

Closed 4 years ago

#15127 closed enhancement (wontfix)

"Pluggable" Parser

Reported by: Kitson Kelly Owned by: bill
Priority: undecided Milestone: tbd
Component: Parser Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:


The "scan" function of the parser should be able to be extensible/pluggable so that its behaviour can be extended without the need for overriding or modification of the dojo/parser code.

To accomplish this the parser could use the dojo/AdapterRegistry to process nodes as the DOM is being walked during a scan. Users could add functionality to the parser like this:

parser.register("parse data-my-attr",
  function(node, parsedNodes, options){
    return node.getAttribute("data-my-attr");
  function(node, parsedNodes, options){
    return {
      ctor: specialCtor,
      instantiate: true,
      stopParser: true
  }, false, true);

This would cause the parser it instantiate an object with the provided constructor and ensure the parser does not walk any of the child nodes for any node that has the "data-my-attr" attribute.

I have a patch for this which I will attach once there is some further discussion on how to best introduce this feature.

Change History (2)

comment:1 Changed 7 years ago by bill

The problem with AdapterRegistry (according to Kitson) is that it throws an exception when none of the registered adapters match. But the parser should skip most DOMNodes.

Regardless, a pluggable architecture would be good, and could be used by dojox/mvc (see code currently in dojox/mvc/parserExtension.js) and also to (optionally) automatically convert HTML5 markup (ex: <input type=date>) to use dijits [on older browsers].

Last edited 7 years ago by bill (previous) (diff)

comment:2 Changed 4 years ago by bill

Resolution: wontfix
Status: newclosed

I think this is no longer relevant in 2.0, where "the parser" is merely a polyfill to match the Web Components spec... in other words all the parser does is set the DOM node's prototype chain and call createdCallback(). At least, that's what delite does.

Note: See TracTickets for help on using tickets.