Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract non-polymer specific logic out of polymer's transformer #17706

Closed
jmesserly opened this issue Mar 21, 2014 · 15 comments
Closed

extract non-polymer specific logic out of polymer's transformer #17706

jmesserly opened this issue Mar 21, 2014 · 15 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. type-enhancement A request for a change that isn't a bug

Comments

@jmesserly
Copy link

Justin brought up a good point: currently Polymer's transformer handles things such as:

  • inlining HTML imports
  • extracting scripts to be passed to dart2js

Neither of those are really Polymer features. We should move them to another transformer.

@jmesserly
Copy link
Author

Removed Type-Defect label.
Added Type-Enhancement label.

@sigmundch
Copy link
Member

Added this to the Later milestone.

@sigmundch
Copy link
Member

Issue #18037 has been merged into this issue.

@sigmundch
Copy link
Member

Pasting here issue #7 to track it all in one place:

A lot of our transformers are generic about web-components features. For example:

  • import-inliner applies to anything that uses html imports
  • @­CustomTag should apply to any custom tag, not just polymer tags

@jmesserly
Copy link
Author

Added Pkg-Polymer label.

@jmesserly
Copy link
Author

Removed Pkg-Polymer label.
Added Pkg-PolymerBuild label.

@jmesserly
Copy link
Author

Removed Library-PolymerBuild label.

@jmesserly
Copy link
Author

Removed Area-Polymer label.
Added Area-Pkg label.

@sigmundch
Copy link
Member

Removed Priority-Unassigned label.
Added Priority-Medium label.

@sigmundch
Copy link
Member

Added Polymer-P-2 label.

@sigmundch
Copy link
Member

Removed this from the Later milestone.

@sigmundch
Copy link
Member

Removed Polymer-P-2 label.
Added Polymer-Milestone-Later label.

@sigmundch
Copy link
Member

Removed Polymer-Milestone-Later label.
Added PolymerMilestone-Later label.

@sigmundch
Copy link
Member

To make this extensible, one though is to include in the annotation the logic for how is the registration supposed to be done. For example, consider we rename @­CustomTag to @­RegisterElement, which has the following code:

class RegisterElement {
  final String tagName;
  const RegisterElement(this.tagName);

  register(Type t) => document.registerElement(tagName, t);

}

A generic transformer can detect that if you have:

  @­RegisterElement('x-foo')
  class Foo ... {}

it can copy the annotation as a const expression and generate a registration call by invoking a method on that const object:

  const RegisterElement('x-foo').register(Foo);

With this approach, it's easy to later add new kinds of registration calls. For example, Polymer can define a subclass of this annotation:

  class RegisterPolymerElement extends RegisterElement {

    @­override
    register(Type t) => Polymer.register(tagName, t);
  }

So the generic transformer can detect that if you have:

  @­RegisterPolymerElement('x-foo')
  class Foo ... {}

it will correctly generate the following call:

  const RegisterPolymerElement('x-foo').register(Foo);

@jmesserly jmesserly added Type-Enhancement area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. labels Sep 23, 2014
@DartBot
Copy link

DartBot commented Jun 5, 2015

This issue has been moved to dart-archive/polymer-dart#383.

@DartBot DartBot closed this as completed Jun 5, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants