File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -104,18 +104,25 @@ DOMElement.prototype.setAttributeNS =
104104 prefix = name . substr ( 0 , colonPosition )
105105 localName = name . substr ( colonPosition + 1 )
106106 }
107- var attributes = this . _attributes [ namespace ] || ( this . _attributes [ namespace ] = { } )
108- attributes [ localName ] = { value : value , prefix : prefix }
107+ if ( this . tagName === 'INPUT' && name === 'type' ) {
108+ this . type = value ;
109+ }
110+ else {
111+ var attributes = this . _attributes [ namespace ] || ( this . _attributes [ namespace ] = { } )
112+ attributes [ localName ] = { value : value , prefix : prefix }
113+ }
109114 }
110115
111116DOMElement . prototype . getAttributeNS =
112117 function _Element_getAttributeNS ( namespace , name ) {
113118 var attributes = this . _attributes [ namespace ] ;
114119 var value = attributes && attributes [ name ] && attributes [ name ] . value
120+ if ( this . tagName === 'INPUT' && name === 'type' ) {
121+ return this . type ;
122+ }
115123 if ( typeof value !== "string" ) {
116124 return null
117125 }
118-
119126 return value
120127 }
121128
Original file line number Diff line number Diff line change @@ -326,11 +326,19 @@ function testDocument(document) {
326326
327327 test ( "input has type=text by default" , function ( assert ) {
328328 var elem = document . createElement ( "input" )
329- assert . equal ( elem . type , "text" ) ;
329+ assert . equal ( elem . getAttribute ( " type" ) , "text" ) ;
330330 assert . equal ( elemString ( elem ) , "<input type=\"text\" />" )
331331 assert . end ( )
332332 } )
333333
334+ test ( "input type=text can be overridden" , function ( assert ) {
335+ var elem = document . createElement ( "input" )
336+ elem . setAttribute ( "type" , "hidden" )
337+ assert . equal ( elem . getAttribute ( "type" ) , "hidden" ) ;
338+ assert . equal ( elemString ( elem ) , "<input type=\"hidden\" />" )
339+ assert . end ( )
340+ } )
341+
334342 test ( "can set and get attributes" , function ( assert ) {
335343 var elem = document . createElement ( "div" )
336344 assert . equal ( elem . getAttribute ( "foo" ) , null )
You can’t perform that action at this time.
0 commit comments