Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15117 closed enhancement (fixed)

Add dojo/aspect for declarative scripting.

Reported by: kitsonk Owned by: bill
Priority: undecided Milestone: 1.8
Component: Parser Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

The parser should support declarative scripts that leverage dojo/aspect.

For example, the parser should support the following markup:

<div data-dojo-type="package/module">
  <script type="dojo/aspect" data-dojo-advice="after" data-dojo-method="method1">
    console.log("I ran after method1");
  </script>
  <script type="dojo/aspect" data-dojo-advice="around" data-dojo-method="method2" 
      data-dojo-args="origFn">
    return function(){
      console.log("this runs before method2");
      origFn.call(this);
      console.log("this runs after method2");
    });
  </script>
  <script type="dojo/aspect" data-dojo-advice="before" data-dojo-method="method3">
    console.log("this run before method3");
    return ["arg1", "arg2"];
</div>

I have a patch for this, but it is co-mingled with some other code and need to separate it out into a discreet patch. I will then attach it to this ticket.

Attachments (1)

parser_aspect.patch (6.1 KB) - added by kitsonk 5 years ago.
Patch to add dojo/aspect declarative scripting support

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by kitsonk

Patch to add dojo/aspect declarative scripting support

comment:1 Changed 5 years ago by kitsonk

I have added the patch to support dojo/aspect in declarative scripting, plus appropriate additions to the unit test case.

comment:2 Changed 5 years ago by bill

  • Milestone changed from tbd to 1.8

Thanks, looks good, I'll check that in. (After I do that please update the reference doc to add info on the new syntax, and remove the section on the deprecated dojo/connect syntax if I didn't remove it already.)

comment:3 Changed 5 years ago by bill

  • Resolution set to fixed
  • Status changed from new to closed

In [28280]:

Add <script type="dojo/aspect" ...> support to parser, fixes #15117 !strict.

Changes are reduced version of patch from kitsonk (CLA on file), thanks! Also fixed a few lingering dojo.* references.

comment:4 Changed 5 years ago by kitsonk

comment:5 Changed 5 years ago by bill

Thanks for the doc update. The only thing is that I wouldn't say that <script type="dojo/method"> is deprecated. Occasionally you need to use it, when you are defining a method that returns a value, such as (IIRC) onSubmit for dijit/form/Form, which returns true or false to approve or cancel the form submission.

(I guess technically you could use around advice for that, but it's strange to use around advice if you aren't calling the original function at all.)

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

comment:6 Changed 5 years ago by kitsonk

Ok, I will update... Thanks.

Note: See TracTickets for help on using tickets.