@@ -351,11 +351,16 @@ interface Attr {
351351 value : string
352352}
353353
354+ export type VElementStyle = Record < string , string > & {
355+ get length ( ) : number
356+ getPropertyValue : ( name : string ) => any
357+ }
358+
354359export class VElement extends VNodeQuery {
355360 _originalTagName : string
356361 _nodeName : string
357362 _attributes : Record < string , string >
358- _styles : Record < string , string > | undefined
363+ _styles : VElementStyle | undefined
359364 _dataset : Record < string , string > | undefined
360365
361366 get nodeType ( ) {
@@ -429,9 +434,13 @@ export class VElement extends VNodeQuery {
429434 }
430435
431436 /// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
432- get style ( ) {
437+ get style ( ) : VElementStyle {
433438 if ( this . _styles == null ) {
434- const styles = Object . assign ( { } , DEFAULTS [ this . tagName . toLowerCase ( ) ] || { } )
439+ // const styles = Object.assign({}, DEFAULTS[this.tagName.toLowerCase()] || {})
440+
441+ const styles : Record < string , string > = { }
442+ let count = 0
443+
435444 const styleString = this . getAttribute ( 'style' )
436445 if ( styleString ) {
437446 let m : string [ ] | null
@@ -441,15 +450,26 @@ export class VElement extends VNodeQuery {
441450
442451 // eslint-disable-next-line no-cond-assign
443452 while ( ( m = re . exec ( styleString ) ) ) {
453+ ++ count
444454 const name = m [ 1 ]
445455 const value = m [ 2 ] . trim ( )
446456 styles [ name ] = value
447457 styles [ toCamelCase ( name ) ] = value
448458 }
449459 }
450- this . _styles = styles
460+ this . _styles = {
461+ get length ( ) : number {
462+ return count
463+ } ,
464+ getPropertyValue ( name : string ) {
465+ return styles [ name ]
466+ } ,
467+
468+ ...DEFAULTS [ this . tagName . toLowerCase ( ) ] ,
469+ ...styles ,
470+ }
451471 }
452- return this . _styles
472+ return this . _styles !
453473 }
454474
455475 /// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
0 commit comments