@@ -228,7 +228,7 @@ test('erases classes and styles', t => {
228
228
const Greeting = ( ) => ( < div > Hello</ div > ) ;
229
229
render (
230
230
< div >
231
- < ElementPortal selector = { `#${ headerId } ` } resetStyle >
231
+ < ElementPortal selector = { `#${ headerId } ` } resetAttributes = { [ 'class' , 'style' ] } >
232
232
< Greeting />
233
233
</ ElementPortal >
234
234
</ div > ,
@@ -239,6 +239,36 @@ test('erases classes and styles', t => {
239
239
t . is ( document . getElementById ( headerId ) . getAttribute ( 'style' ) , null ) ;
240
240
} ) ;
241
241
242
+ test ( 'erases all attributes' , t => {
243
+ const node = document . createElement ( 'div' ) ;
244
+ document . body . appendChild ( node ) ;
245
+ const headerId = uniqueId ( ) ;
246
+ const appId = uniqueId ( ) ;
247
+ node . innerHTML = `
248
+ <div id="${ headerId } " class="foo" data-bar="baz" qux>
249
+ </div>
250
+ <div id="${ appId } ">
251
+ </div>
252
+ ` ;
253
+ const headerElement = document . getElementById ( headerId ) ;
254
+ t . is ( headerElement . classList . length , 1 ) ;
255
+ t . is ( headerElement . getAttribute ( 'data-bar' ) , 'baz' ) ;
256
+ t . is ( headerElement . getAttribute ( 'quz' ) , null ) ;
257
+ const Greeting = ( ) => ( < div > Hello</ div > ) ;
258
+ render (
259
+ < div >
260
+ < ElementPortal selector = { `#${ headerId } ` } resetAttributes = { true } >
261
+ < Greeting />
262
+ </ ElementPortal >
263
+ </ div > ,
264
+ document . getElementById ( appId )
265
+ ) ;
266
+ t . is ( headerElement . textContent , 'Hello' ) ;
267
+ t . is ( headerElement . classList . length , 0 ) ;
268
+ t . is ( headerElement . getAttribute ( 'data-bar' ) , null ) ;
269
+ t . is ( headerElement . getAttribute ( 'qux' ) , null ) ;
270
+ } ) ;
271
+
242
272
test ( 'transfers context to the portal' , t => {
243
273
const store = createStore ( ( state = 0 , action ) => {
244
274
if ( action && action . type === 'INC' ) {
0 commit comments