File tree 3 files changed +73
-2
lines changed
3 files changed +73
-2
lines changed Original file line number Diff line number Diff line change 145
145
for ( var k = 0 ; k < b . parts . length ; k ++ ) {
146
146
var p = b . parts [ k ] ;
147
147
if ( ! p . literal ) {
148
- p . signature = this . _parseMethod ( p . value ) ;
149
- if ( ! p . signature ) {
148
+ var signature = this . _parseMethod ( p . value ) ;
149
+ if ( signature ) {
150
+ var method = signature . method ;
151
+ if ( this . properties [ method ] ) {
152
+ var args = signature . args || [ ] ;
153
+ args . push ( this . _parseArg ( method ) ) ;
154
+ signature . args = args ;
155
+ signature . static = false ;
156
+ }
157
+ p . signature = signature ;
158
+ } else {
150
159
p . model = this . _modelForPath ( p . value ) ;
151
160
}
152
161
}
Original file line number Diff line number Diff line change 582
582
} ) ( ) ;
583
583
</ script >
584
584
</ dom-module >
585
+
586
+ < dom-module id ="x-bind-computed-property ">
587
+ < template >
588
+ < div id ="check "> [[translate('Hello World.')]]</ div >
589
+ </ template >
590
+ < script >
591
+ Polymer ( {
592
+ is : 'x-bind-computed-property' ,
593
+ properties : {
594
+ translate : {
595
+ type : Function ,
596
+ computed : '_computeTranslateFn(translator)'
597
+ } ,
598
+ translator : {
599
+ type : Function ,
600
+ value : function ( ) {
601
+ return function ( message ) {
602
+ return 'translated: ' + message ;
603
+ }
604
+ }
605
+ } ,
606
+ } ,
607
+
608
+ _computeTranslateFn : function ( translator ) {
609
+ return function ( message ) {
610
+ return translator ( message ) ;
611
+ }
612
+ } ,
613
+
614
+ } ) ;
615
+ </ script >
616
+ </ dom-module >
Original file line number Diff line number Diff line change 285
285
286
286
< script >
287
287
288
+ suite ( 'computed properties' , function ( ) {
289
+
290
+ var el ;
291
+
292
+ setup ( function ( ) {
293
+
294
+ } ) ;
295
+
296
+ teardown ( function ( ) {
297
+ document . body . removeChild ( el ) ;
298
+ } ) ;
299
+
300
+ test ( 'x' , function ( ) {
301
+ el = document . createElement ( 'x-bind-computed-property' ) ;
302
+ document . body . appendChild ( el ) ;
303
+
304
+ assert . equal ( el . $ . check . textContent , 'translated: Hello World.' ) ;
305
+
306
+ el . translator = function ( message ) {
307
+ return 'changed: ' + message ;
308
+ }
309
+
310
+ assert . equal ( el . $ . check . textContent , 'changed: Hello World.' ) ;
311
+ } ) ;
312
+
313
+ } ) ;
314
+
315
+ </ script >
316
+
317
+ < script >
288
318
suite ( '2-way binding effects between elements' , function ( ) {
289
319
290
320
var el ;
You can’t perform that action at this time.
0 commit comments