File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 11
11
12
12
// element api
13
13
14
+ var observationBlacklist = [ 'attribute' ] ;
15
+
14
16
var properties = {
15
17
inferObservers : function ( prototype ) {
16
18
// called before prototype.observe is chained to inherited object
17
19
var observe = prototype . observe , property ;
18
20
for ( var n in prototype ) {
19
21
if ( n . slice ( - 7 ) === 'Changed' ) {
20
- if ( ! observe ) {
21
- observe = ( prototype . observe = { } ) ;
22
+ property = n . slice ( 0 , - 7 ) ;
23
+ if ( this . canObserveProperty ( property ) ) {
24
+ if ( ! observe ) {
25
+ observe = ( prototype . observe = { } ) ;
26
+ }
27
+ observe [ property ] = observe [ property ] || n ;
22
28
}
23
- property = n . slice ( 0 , - 7 )
24
- observe [ property ] = observe [ property ] || n ;
25
29
}
26
30
}
27
31
} ,
32
+ canObserveProperty : function ( property ) {
33
+ return ( observationBlacklist . indexOf ( property ) < 0 ) ;
34
+ } ,
28
35
explodeObservers : function ( prototype ) {
29
36
// called before prototype.observe is chained to inherited object
30
37
var o = prototype . observe ;
Original file line number Diff line number Diff line change 24
24
< script >
25
25
( function ( ) {
26
26
var changes = 0 ;
27
- var doneChanges = 2 ;
27
+ var doneChanges = 3 ;
28
28
function checkDone ( ) {
29
29
if ( doneChanges == ++ changes ) {
30
30
done ( ) ;
33
33
34
34
Polymer ( 'x-test' , {
35
35
bar : '' ,
36
+ attributeChangedCount : 0 ,
36
37
ready : function ( ) {
38
+ this . attribute = 'foo' ;
39
+ this . deliverChanges ( ) ;
40
+ chai . assert . equal ( this . attributeChangedCount , 0 , 'attributeChanged does not observe property attribute' ) ;
41
+ this . setAttribute ( 'nog' , 'nog' ) ;
37
42
this . bar = 'bar' ;
38
43
setTimeout ( function ( ) {
39
44
this . zonk = 'zonk' ;
46
51
zonkChanged : function ( ) {
47
52
chai . assert . equal ( this . zonk , 'zonk' , 'change calls *Changed without prototype value' )
48
53
checkDone ( ) ;
54
+ } ,
55
+ attributeChanged : function ( ) {
56
+ this . attributeChangedCount ++ ;
57
+ chai . assert . equal ( this . getAttribute ( 'nog' ) , 'nog' , 'attributeChanged called in response to an attribute value changing' )
58
+ checkDone ( ) ;
49
59
}
50
60
} ) ;
51
61
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments