Code coverage report for htmlcs/lib/rules/rel-stylesheet.js

Statements: 100% (6 / 6)      Branches: 100% (4 / 4)      Functions: 100% (2 / 2)      Lines: 100% (6 / 6)      Ignored: none     

All files » htmlcs/lib/rules/ » rel-stylesheet.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26          1             37 36     1 4 2              
/**
 * @file rule: rel-stylesheet
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'rel-stylesheet',
 
    desc: 'Attribute "rel" of <link> should be set as "stylesheet".',
 
    lint: function (enable, document, reporter) {
        if (!enable) {
            return;
        }
 
        document.querySelectorAll('link').forEach(function (element) {
            if (!element.getAttribute('rel')) {
                reporter.warn(element, '022', 'Attribute "rel" of <link> should be set as "stylesheet".');
            }
        });
 
    }
 
};