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

allow to add extra information from code or as a separate transformer #19875

Closed
DartBot opened this issue Jul 8, 2014 · 6 comments
Closed

allow to add extra information from code or as a separate transformer #19875

DartBot opened this issue Jul 8, 2014 · 6 comments
Labels
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.

Comments

@DartBot
Copy link

DartBot commented Jul 8, 2014

This issue was originally filed by @jolleekin


I was trying to bind the text of a button to a resource string.
nodeBind(button.firstChild).bind('text', 'resources.commands.save');

This in turn creates a PathObserver, which then creates a PropertyPath. PropertyPath uses smoke.nameToSymbol to convert each path segment into a Symbol.

The created PropertyPath was expected to have 3 symbols: #resources, #commands, and #save, but it actually contained #resources, null, and null.

Before transformation, smoke.nameToSymbol uses new Symbol(name); however, after transformation, smoke.nameToSymbol calls GeneratedSymbolConverterService.nameToSymbol, which uses a symbol cache. The cache didn't contain #commands and #save, so nodeBind failed.

/// Implements [SymbolConverterService] using a static configuration.
class GeneratedSymbolConverterService implements SymbolConverterService {
  Map<Symbol, String> _names;

  /// A map from strings to symbols (the reverse of [names]).
  final Map<String, Symbol> _symbols;

  GeneratedSymbolConverterService(StaticConfiguration configuration)
      : _names = configuration.names,
        _symbols = {} {
    _names.forEach((k, v) { _symbols[v] = k; });
  }

  String symbolToName(Symbol symbol) => _names[symbol];
  Symbol nameToSymbol(String name) => _symbols[name];
}

@sigmundch
Copy link
Member

The problem is that all these bindings and PathObservers are actually reflective. We use smoke as a library that implements the reflective API. When you run in Dartium, this API is implemented with dart:mirrors, but when you build the app with the polymer transformers, we replace the use of mirrors with generated code to help dart2js optimize your app.

To generate the code we need, the polymer transformers parse your app and discover every expression in a template, among other things. Expressions within Dart code, like your example above, are not discovered so we don't know how to generate code for them. That's basically why there is no entry for #commands or #save.

In the future I'd like to add the option of adding your own transformer phase that tells smoke to generate some extra symbols and such, but this is not available today. I'll keep this bug open to track this.

Meanwhile, the best way to work around this issue is to make sure those symbols are mentioned in your HTML templates somewhere. It should be enough to define a polymer-element element whose template uses those symbols (even if the element is not used anywhere).


Removed Priority-Unassigned label.
Added Priority-Medium, Pkg-Smoke, Area-Pkg, Polymer-P-1, Triaged labels.

@sigmundch
Copy link
Member

This might need the same changes we need to fix issue #17872, though.


Marked this as being blocked by #17872.
Changed the title to: "allow to add extra information from code or as a separate transformer".

@sigmundch
Copy link
Member

Removed Polymer-P-1 label.
Added Polymer-Milestone-Next label.

@sigmundch
Copy link
Member

Added PolymerMilestone-Next label.

@sigmundch
Copy link
Member

Removed Polymer-Milestone-Next label.

@DartBot DartBot added Type-Defect area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. labels Jul 9, 2014
@DartBot
Copy link
Author

DartBot commented Jun 4, 2015

This issue has been moved to dart-archive/smoke#10.

@DartBot DartBot closed this as completed Jun 4, 2015
@kevmoo kevmoo removed the triaged label 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.
Projects
None yet
Development

No branches or pull requests

3 participants