File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,7 +96,25 @@ module.exports = {
9696 }
9797
9898 const value = typeAttr . value ;
99- if ( value && value . type === 'GlimmerTextNode' ) {
99+
100+ // Valueless attribute form (`<input type />`) — per HTML spec, a
101+ // present-but-empty type attribute resolves to the missing-value
102+ // default ("Text state"). That's the same runtime result as
103+ // `type=""`, which we already flag. Treat them consistently:
104+ // flag as invalid('') and autofix to `type="text"`.
105+ if ( ! value ) {
106+ context . report ( {
107+ node : typeAttr ,
108+ messageId : 'invalid' ,
109+ data : { value : '' } ,
110+ fix ( fixer ) {
111+ return fixer . replaceText ( typeAttr , 'type="text"' ) ;
112+ } ,
113+ } ) ;
114+ return ;
115+ }
116+
117+ if ( value . type === 'GlimmerTextNode' ) {
100118 const typeValue = value . chars . toLowerCase ( ) ;
101119 if ( typeValue === '' ) {
102120 context . report ( {
Original file line number Diff line number Diff line change @@ -36,6 +36,15 @@ const invalidHbs = [
3636 output : '<input type="text" />' ,
3737 errors : [ { message : errInvalid ( 'TEXTY' ) } ] ,
3838 } ,
39+ // Valueless type attribute — per HTML spec resolves to the missing-value
40+ // default (Text state), same runtime result as `type=""`. Flag and autofix
41+ // to `type="text"`. (Output loses the pre-slash space because the
42+ // valueless attr range ends at `type`; prettier will re-insert if needed.)
43+ {
44+ code : '<input type />' ,
45+ output : '<input type="text"/>' ,
46+ errors : [ { message : errInvalid ( '' ) } ] ,
47+ } ,
3948] ;
4049
4150const requireExplicitInvalid = [
You can’t perform that action at this time.
0 commit comments