File tree 2 files changed +20
-2
lines changed 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ import {location} from 'vfile-location'
61
61
import { webNamespaces } from 'web-namespaces'
62
62
63
63
const own = { } . hasOwnProperty
64
+ /** @type {unknown } */
65
+ // type-coverage:ignore-next-line
66
+ const proto = Object . prototype
64
67
65
68
/**
66
69
* Transform a `parse5` AST to hast.
@@ -215,8 +218,11 @@ function element(state, node) {
215
218
216
219
while ( ++ index < node . attrs . length ) {
217
220
const attribute = node . attrs [ index ]
218
- props [ ( attribute . prefix ? attribute . prefix + ':' : '' ) + attribute . name ] =
219
- attribute . value
221
+ const name =
222
+ ( attribute . prefix ? attribute . prefix + ':' : '' ) + attribute . name
223
+ if ( ! own . call ( proto , name ) ) {
224
+ props [ name ] = attribute . value
225
+ }
220
226
}
221
227
222
228
// Build.
Original file line number Diff line number Diff line change @@ -355,6 +355,18 @@ test('fromParse5', () => {
355
355
} ,
356
356
'should transform svg'
357
357
)
358
+
359
+ assert . deepEqual (
360
+ fromParse5 ( parseFragment ( '<x constructor y />' ) , { space : 'svg' } ) ,
361
+ {
362
+ type : 'root' ,
363
+ children : [
364
+ { type : 'element' , tagName : 'x' , properties : { y : '' } , children : [ ] }
365
+ ] ,
366
+ data : { quirksMode : false }
367
+ } ,
368
+ 'should ignore prototypal props'
369
+ )
358
370
} )
359
371
360
372
test ( 'fixtures' , async ( ) => {
You can’t perform that action at this time.
0 commit comments