Code coverage report for htmlcs/lib/rules/css-in-head.js

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

All files » htmlcs/lib/rules/ » css-in-head.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 27          1             37 36     1   1 4 2            
/**
 * @file rule: css-in-head
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'css-in-head',
 
    desc: 'All css contents are recommended to be imported in <head>.',
 
    lint: function (enable, document, reporter) {
        if (!enable) {
            return;
        }
 
        var head = document.querySelector('head');
 
        document.querySelectorAll('link[rel="stylesheet"], style').forEach(function (css) {
            if (!(head && head.contains(css))) {
                reporter.warn(css, '008', 'Css contents are recommended to be imported in <head>.');
            }
        });
    }
 
};