File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 40
40
}
41
41
}
42
42
43
+ /**
44
+ * Implements standard custom elements getter to observes the attributes
45
+ * listed in `properties`. These are camel to dash cased.
46
+ */
43
47
static get observedAttributes ( ) {
44
48
const props = this . properties ;
45
- return props ? Object . keys ( props ) : [ ] ;
49
+ return props ? Object . keys ( props ) . map ( p => {
50
+ return this . prototype . _attributeNameForProperty ( p ) ;
51
+ } ) : [ ] ;
46
52
}
47
53
48
54
/**
60
66
}
61
67
62
68
/**
63
- * Overrides default behavior and adds a call to `finalize`.
69
+ * Overrides default behavior and adds a call to `finalize` which lazily
70
+ * configures the element's property accessors.
64
71
* @override
65
72
*/
66
73
_initializeProperties ( ) {
67
74
this . constructor . _ensureFinalized ( this . localName ) ;
68
75
super . _initializeProperties ( ) ;
69
76
}
70
77
78
+ /**
79
+ * Overrides default behavior to use `type` information stored in the
80
+ * static `properties` object. This allows attributes to be converted to
81
+ * the coressponding type given in `properties`. Atributes are dash to
82
+ * camel cased.
83
+ */
71
84
_attributeToProperty ( attribute , value , type ) {
72
85
if ( ! type ) {
73
86
const property = this . _propertyNameForAttribute ( attribute ) ;
78
91
super . _attributeToProperty ( attribute , value , type ) ;
79
92
}
80
93
94
+ /**
95
+ * Called when the element is added to a document.
96
+ * Calls `_enableProperties` to turn on property system from
97
+ * `PropertyAccessors`.
98
+ */
81
99
connectedCallback ( ) {
82
100
this . _enableProperties ( ) ;
83
101
}
Original file line number Diff line number Diff line change 149
149
150
150
static get properties ( ) {
151
151
return Object . assign ( {
152
- prop3 : String
152
+ prop3 : String ,
153
+ camelCase : String
153
154
} , super . properties ) ;
154
155
}
155
156
195
196
196
197
< test-fixture id ="sub-mixin-element-attr ">
197
198
< template >
198
- < sub-mixin-element prop ="attr " prop2 ="attr " prop3 ="attr " mixin ="5 "> </ sub-mixin-element >
199
+ < sub-mixin-element prop ="attr " prop2 ="attr " prop3 ="attr " mixin ="5 " camel-case =" camelCase " > </ sub-mixin-element >
199
200
</ template >
200
201
</ test-fixture >
201
202
343
344
assert . equal ( fixtureEl . prop , 'attr' ) ;
344
345
assert . equal ( fixtureEl . prop2 , 'attr' ) ;
345
346
assert . equal ( fixtureEl . prop3 , 'attr' ) ;
347
+ assert . equal ( fixtureEl . camelCase , 'camelCase' ) ;
346
348
assert . equal ( fixtureEl . mixin , 5 ) ;
347
- assert . equal ( fixtureEl . _callAttributeChangedCallback , 4 ) ;
349
+ assert . equal ( fixtureEl . _callAttributeChangedCallback , 5 ) ;
348
350
assert . isTrue ( fixtureEl . hasAttribute ( 'tabindex' ) ) ;
349
351
assert . equal ( fixtureEl . getAttribute ( 'role' ) , 'button' ) ;
350
352
assert . equal ( fixtureEl . getAttribute ( 'mixinattr' ) , 'mixinattr' ) ;
351
- assert . equal ( fixtureEl . getAttribute ( 'submixinattr' ) , 'submixinattr' ) ;
352
353
} ) ;
353
354
354
355
} ) ;
You can’t perform that action at this time.
0 commit comments