Skip to content

Commit a38ddef

Browse files
authored
Add rel to list of sorted attributes (#1579)
1 parent 0494c1e commit a38ddef

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

dist/core/rules/attr-sorted.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/htmlhint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@
466466
'src',
467467
'for',
468468
'type',
469+
'rel',
469470
'href',
470471
'value',
471472
'title',

dist/htmlhint.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/rules/attr-sorted.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
'src',
1313
'for',
1414
'type',
15+
'rel',
1516
'href',
1617
'value',
1718
'title',

test/rules/attr-sorted.spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,18 @@ describe(`Rules: ${ruleId}`, () => {
4343
expect(messages[0].rule.id).toBe(ruleId)
4444
expect(messages[0].message).toContain('["type","img","id","font"]')
4545
})
46+
47+
it('link tag with rel before href should not throw error', () => {
48+
const code = '<link rel="stylesheet" href="https://example.com/style.css">'
49+
const messages = HTMLHint.verify(code, ruleOptions)
50+
expect(messages.length).toBe(0)
51+
})
52+
53+
it('link tag with href before rel should throw error', () => {
54+
const code = '<link href="https://example.com/style.css" rel="stylesheet">'
55+
const messages = HTMLHint.verify(code, ruleOptions)
56+
expect(messages.length).toBe(1)
57+
expect(messages[0].rule.id).toBe(ruleId)
58+
expect(messages[0].message).toContain('["href","rel"]')
59+
})
4660
})

0 commit comments

Comments
 (0)