diff --git a/lib/rules/style/sheet.js b/lib/rules/style/sheet.js index 53bffdfba..b4a38bf7c 100644 --- a/lib/rules/style/sheet.js +++ b/lib/rules/style/sheet.js @@ -17,16 +17,23 @@ exports.name = rule; exports.check = function (sr, done) { if (!sr.config.styleSheet) return done(); const url = `https://www.w3.org/StyleSheets/TR/2016/${sr.config.styleSheet}`; + const dark = 'https://www.w3.org/StyleSheets/TR/2016/dark'; const sels = [ `head > link[rel=stylesheet][href='${url}']`, - `head > link[rel=stylesheet][href='https:${url}']`, `head > link[rel=stylesheet][href='${url}.css']`, - `head > link[rel=stylesheet][href='https:${url}.css']`, ]; const lnk = sr.jsDocument.querySelectorAll(sels.join(', ')); if (!lnk.length) sr.error(missing, 'not-found'); - else if (util.nextAll(lnk, 'link[rel=stylesheet], style').length) { - sr.error(notLast, 'last'); + else { + const siblings = util.nextAll(lnk, 'link[rel=stylesheet], style'); + if ( + siblings.length || + (siblings.length === 1 && + (siblings[0].href !== dark || + siblings[0].href !== `${dark}.css`)) + ) { + sr.error(notLast, 'last'); + } } done(); }; diff --git a/test/docs/headers/simple-dark-mode.html b/test/docs/headers/simple-dark-mode.html new file mode 100644 index 000000000..e5f5e2b8c --- /dev/null +++ b/test/docs/headers/simple-dark-mode.html @@ -0,0 +1,103 @@ + + +
+ ++ Please check the errata for any errors or issues reported since publication. +
++ Copyright © 1995-2017 + W3C® + (MIT, + ERCIM, + Keio, + Beihang). + W3C + liability, + trademark and + document use + rules apply. +
++ We are the internets! +
+This section describes the status of this document at the time of its publication. + Other documents may supersede this document. A list of current W3C publications and the + latest revision of this technical report can be found in the + W3C technical reports index at + https://www.w3.org/TR/.
++ If you wish to make comments regarding this document, please send them to + public-html@w3.org + (subscribe, + archives). +
++ It's a valid test! +
++ Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a + draft document and may be updated, replaced or obsoleted by other documents at any time. It is + inappropriate to cite this document as other than work in progress. +
++ This document was produced by a group operating under the + 5 February 2004 + W3C Patent Policy. + W3C maintains a + public list of + any patent disclosures made in connection with the deliverables of the group; that page + also includes instructions for disclosing a patent. An individual who has actual knowledge of + a patent which the individual believes contains + Essential + Claim(s) must disclose the information in accordance with + section 6 of the + W3C Patent Policy. +
+ + + diff --git a/test/rules.js b/test/rules.js index bf1425e48..766517b2a 100644 --- a/test/rules.js +++ b/test/rules.js @@ -475,6 +475,10 @@ const tests = { style: { sheet: [ { doc: 'headers/simple.html', config: { styleSheet: 'W3C-WD' } }, + { + doc: 'headers/simple-dark-mode.html', + config: { styleSheet: 'W3C-WD' }, + }, { doc: 'headers/fails.html', config: { styleSheet: 'W3C-WD' },