@@ -155,11 +155,15 @@ describe('initializeAttrs', () => {
155155
156156describe ( 'attr' , ( ) => {
157157 class AttrTestElement extends HTMLElement { }
158+ attr ( AttrTestElement . prototype , 'foo' )
159+ attr ( AttrTestElement . prototype , 'bar' )
158160 window . customElements . define ( 'attr-test-element' , AttrTestElement )
159161
162+ class ExtendedAttrTestElement extends AttrTestElement { }
163+ attr ( ExtendedAttrTestElement . prototype , 'baz' )
164+ window . customElements . define ( 'extended-attr-test-element' , ExtendedAttrTestElement )
165+
160166 it ( 'populates the "default" list for initializeAttrs' , ( ) => {
161- attr ( AttrTestElement . prototype , 'foo' )
162- attr ( AttrTestElement . prototype , 'bar' )
163167 const instance = document . createElement ( 'attr-test-element' )
164168 instance . foo = 'hello'
165169 initializeAttrs ( instance )
@@ -169,6 +173,20 @@ describe('attr', () => {
169173 expect ( instance . getAttribute ( 'data-foo' ) ) . to . equal ( 'hello' )
170174 expect ( instance . getAttribute ( 'data-bar' ) ) . to . equal ( '' )
171175 } )
176+
177+ it ( 'includes attrs from extended elements' , ( ) => {
178+ const instance = document . createElement ( 'extended-attr-test-element' )
179+ instance . bar = 'hello'
180+ instance . baz = 'world'
181+ initializeAttrs ( instance )
182+ expect ( instance ) . to . have . property ( 'foo' , '' )
183+ expect ( instance ) . to . have . property ( 'bar' , 'hello' )
184+ expect ( instance ) . to . have . property ( 'baz' , 'world' )
185+ expect ( instance . getAttributeNames ( ) ) . to . eql ( [ 'data-baz' , 'data-foo' , 'data-bar' ] )
186+ expect ( instance . getAttribute ( 'data-foo' ) ) . to . equal ( '' )
187+ expect ( instance . getAttribute ( 'data-bar' ) ) . to . equal ( 'hello' )
188+ expect ( instance . getAttribute ( 'data-baz' ) ) . to . equal ( 'world' )
189+ } )
172190} )
173191
174192describe ( 'defineObservedAttributes' , ( ) => {
@@ -200,4 +218,12 @@ describe('defineObservedAttributes', () => {
200218 TestElement . observedAttributes = [ 'a' , 'b' , 'c' ]
201219 expect ( TestElement . observedAttributes ) . to . eql ( [ 'data-foo' , 'a' , 'b' , 'c' ] )
202220 } )
221+
222+ it ( 'will reflect values from extended elements' , ( ) => {
223+ class TestElement extends HTMLElement { }
224+ class ExtendedTestElement extends TestElement { }
225+ defineObservedAttributes ( ExtendedTestElement )
226+ attr ( TestElement . prototype , 'foo' )
227+ expect ( ExtendedTestElement . observedAttributes ) . to . eql ( [ 'data-foo' ] )
228+ } )
203229} )
0 commit comments