Code coverage report for htmlcs/lib/rules/ie-edge.js

Statements: 100% (12 / 12)      Branches: 92.86% (13 / 14)      Functions: 100% (2 / 2)      Lines: 100% (12 / 12)      Ignored: none     

All files » htmlcs/lib/rules/ » ie-edge.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 28 29 30 31 32 33 34 35 36 37 38 39          1             37 34     3   3 1     2 2 5       1       2 1          
/**
 * @file rule: ie-edge
 * @author nighca<nighca@live.cn>
 */
 
module.exports = {
 
    name: 'ie-edge',
 
    desc: '<meta http-equiv="X-UA-Compatible" content="IE=Edge"> recommended.',
 
    lint: function (enable, document, reporter) {
        if (!enable) {
            return;
        }
 
        var head = document.querySelector('head');
 
        if (!head) {
            return;
        }
 
        var hasEdgeMeta = false;
        head.querySelectorAll('meta').forEach(function (meta) {
            if (
                (meta.getAttribute('http-equiv') || '').toLowerCase() === 'x-ua-compatible' &&
                (meta.getAttribute('content') || '').toLowerCase() === 'ie=edge'
            ) {
                hasEdgeMeta = true;
            }
        });
 
        if (!hasEdgeMeta) {
            reporter.warn(head, '011', '<meta http-equiv="X-UA-Compatible" content="IE=Edge"> recommended.');
        }
    }
 
};