File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 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'
6161import { webNamespaces } from 'web-namespaces'
6262
6363const own = { } . hasOwnProperty
64+ /** @type {unknown } */
65+ // type-coverage:ignore-next-line
66+ const proto = Object . prototype
6467
6568/**
6669 * Transform a `parse5` AST to hast.
@@ -215,8 +218,11 @@ function element(state, node) {
215218
216219 while ( ++ index < node . attrs . length ) {
217220 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+ }
220226 }
221227
222228 // Build.
Original file line number Diff line number Diff line change @@ -355,6 +355,18 @@ test('fromParse5', () => {
355355 } ,
356356 'should transform svg'
357357 )
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+ )
358370} )
359371
360372test ( 'fixtures' , async ( ) => {
You can’t perform that action at this time.
0 commit comments