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

model.runtimeType.toString() in Polymer expression doesn't produce an output #20980

Closed
DartBot opened this issue Sep 17, 2014 · 6 comments
Closed
Assignees
Labels

Comments

@DartBot
Copy link

@DartBot DartBot commented Sep 17, 2014

This issue was originally filed by @zoechi


{{model.runtimeType}}
shows 'Foo' but
{{model.runtimeType.toString()}}
produces no output

I tried to use it like

<template if="{{model.runtimeType.toString() == 'Foo'}}">

but that didn't work
see http://stackoverflow.com/questions/25878785 for more details

Dart VM version: 1.7.0-edge.40314 (Tue Sep 16 05:31:11 2014) on "linux_x64"
Polymer 0.14.0+1

@jakemac53
Copy link
Contributor

@jakemac53 jakemac53 commented Sep 18, 2014

Definitely was able to get a repro on this, pretty bizarre. I actually get an error from smoke error saying that String doesn't have a toString symbol, so it seems like it thinks that runtimeType is a String for some reason?


Set owner to @jakemac53.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@jakemac53
Copy link
Contributor

@jakemac53 jakemac53 commented Sep 18, 2014

Added Started label.

@sigmundch
Copy link
Member

@sigmundch sigmundch commented Sep 18, 2014

turns out "String" here is because that's the string representation of the String type.

The error seems to be that smoke assumes that

  smoke.invoke(A, #foo)

is a static method call. Turns out that no, in this case it is an instance method.

@jakemac53
Copy link
Contributor

@jakemac53 jakemac53 commented Sep 18, 2014

Fixed in r40469 and released a new smoke version 0.2.1+1


Removed Pkg-Polymer label.
Added Pkg-Smoke, Fixed labels.

@sigmundch
Copy link
Member

@sigmundch sigmundch commented Sep 18, 2014

Note that with dart2js minification there is no guarantee that model.runtimeType.toString() will be 'Foo', it might be mangled.

It might be better for your code to expose the expressions you need in a different way. For example:

if="{{mode.runtimeType == fooType}}"

Where fooType is a getter in your custom-element that returns Foo.

You could also do the updates in 2 steps (this however means that the UI will require 2 rounds of observable notifications, rather than 1:

@observable
bool isFoo;

@ObserveProperty('model')
updateIsFoo() {
  isFoo = model.runtimeType == Foo;
}

Cheers,
Siggi

@DartBot
Copy link
Author

@DartBot DartBot commented Jun 5, 2015

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants