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
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.

Comments

@DartBot
Copy link

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

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

Added Started label.

@sigmundch
Copy link
Member

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

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

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 DartBot added Type-Defect area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams. labels Sep 18, 2014
@DartBot
Copy link
Author

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
area-pkg Used for miscellaneous pkg/ packages not associated with specific area- teams.
Projects
None yet
Development

No branches or pull requests

3 participants