Repository navigation
Cannot find function or filter #1102
Description
Activity
What happens if you put this in the
readyfunction?PolymerExpressions.prototype.getMin = function(input) { if (input === 'daily') return 1; else if (input === 'weekly') return 10; }; PolymerExpressions.prototype.getMax = function(input) { if (input === 'daily') return 1000; else if (input === 'weekly') return 5000; }; PolymerExpressions.prototype.getStep = function(input) { if (input === 'daily') return 5; else if (input === 'weekly') return 50; };PS consider making a http://jsbin.com to show case the problem, its easier for amatures like me to answer the question :)
if I add all those expressions inside ready each error repeats twice on page load.
(sorry still trying to figure out to make polymer work in jsbin)thanks for the jsbin - I did slight modification (used direct components from polymer website instead of ../bower_components)
live preview link: http://jsbin.com/nonetirovu
If i open the chrome console I see the same errors, do you see in your browser?
lol it even crashed my browser if I click on weekly
@robdodson why is this breaking the internet :P
<paper-slider min="{{type | getMin}}" max="{{type | getMax}}" step="{{type | getStep}}" pin="true"> </paper-slider>
Note that without paper-slider it works
I've realised now that your filters don't return a value when the type is not set or unknown so the filters are being cached as undefined.
I think you have two choices here to fix this:
- ensure the type is set
Polymer('my-element', { type: 'daily', // ensures the type is set ready: function() { this.type = 'daily'; } });or 2. handle unknown\undefined types
PolymerExpressions.prototype.getMin = function(input) { if (input === 'daily') return 1; else if (input === 'weekly') return 10; else return 0; }; PolymerExpressions.prototype.getMax = function(input) { if (input === 'daily') return 1000; else if (input === 'weekly') return 5000; else return 0; }; PolymerExpressions.prototype.getStep = function(input) { if (input === 'daily') return 5; else if (input === 'weekly') return 50; else return 0; };Suggesting to build in
undefinedfail system in polymer because does bugs are very hard to find!@pflannery - initializing
type: 'daily'did the trick. I also see your point about handling undefined case as well - will do.@gertcuykens - I did notice the "freeze" issue. But now if I use
value="{{value}}"attr for paper-slider it no longer freezes - I guess it needed some variable to bind the value.I think I'll close the issue. Thanks guys.
it fails when we use filter in
paper-elements
it looks like external components do not see application filters
Below is a sample my-element which uses use custom filters. The custom filter functionality works but console shows weird errors only on page load.
Till now can't find any faults in the functionality or the GUI behavior,