<commit_before>var _ = require('underscore'),
    urlTools = require('urltools'),
    cssom = require('cssom-papandreou'),
    AssetGraph = require('../'),
    uglifyJs = AssetGraph.JavaScript.uglifyJs;

module.exports = function (queryObj, options) {
    options = options || {};
    var bundleStrategyName = options.strategyName || 'oneBundlePerIncludingAsset';

    return function bundleRelations(assetGraph) {
        function getDiscriminatorForRelation(relation) {
            var discriminatorFragments = [],
                i,
                attribute;
            if (relation.to.isLoaded) {
                discriminatorFragments.push('isLoaded');
            }
            if (relation.conditionalComments) {
                Array.prototype.push.apply(discriminatorFragments, _.pluck(relation.conditionalComments, 'nodeValue'));
            }
            if (relation.type === 'HtmlStyle') {
                discriminatorFragments.push(relation.node.getAttribute('media') || 'all');
                for (i = 0 ; i < relation.node.attributes.length ; i += 1) {
                    attribute = relation.node.attributes[i];
                    if (attribute.name !== 'media' &&
                        (attribute.name !== 'rel' || attribute.value !== 'stylesheet') &&
                        (attribute.name !== 'href' || relation.node.nodeName.toLowerCase() !== 'link') &&
                        (attribute.name !== 'type' || attribute.value !== 'text/css' || !relation.to || relation.to.type !== 'Css')) {
                        return 'nobundle';
                    }
                }
            } else if (relation.type === 'HtmlScript') {
                var isInsideHead = false,
                    parentNode = relation.node.parentNode;
                while (parentNode) {
                    if (parentNode.nodeName.toLowerCase() === 'head') {
                        isInsideHead = true;
                        break;
                    }
                    parentNode = parentNode.parentNode;
                }
                if (isInsideHead) {
                    discriminatorFragments.push('head');
                } else {
                    discriminatorFragments.push('body');
                }

                if (relation.to.strict) {
                    discriminatorFragments.push('strict');
                    var warning = new Error('Global "use strict"-directive. Splitting into multiple bundles to avoid side effects.');
                    warning.asset = relation.to;
                    assetGraph.emit('info', warning);
                }
                if (relation.node.getAttribute('defer') === 'defer') {<commit_msg>bundleRelations: Don't bundle stylesheets found in <head> with ones found in <body>.<commit_after>var _ = require('underscore'),
    urlTools = require('urltools'),
    cssom = require('cssom-papandreou'),
    AssetGraph = require('../'),
    uglifyJs = AssetGraph.JavaScript.uglifyJs;

module.exports = function (queryObj, options) {
    options = options || {};
    var bundleStrategyName = options.strategyName || 'oneBundlePerIncludingAsset';

    return function bundleRelations(assetGraph) {
        function getDiscriminatorForRelation(relation) {
            var discriminatorFragments = [],
                i,
                attribute;
            if (relation.to.isLoaded) {
                discriminatorFragments.push('isLoaded');
            }
            var isInsideHead = false,
                parentNode = relation.node.parentNode;
            while (parentNode) {
                if (parentNode.nodeName.toLowerCase() === 'head') {
                    isInsideHead = true;
                    break;
                }
                parentNode = parentNode.parentNode;
            }
            if (isInsideHead) {
                discriminatorFragments.push('head');
            } else {
                discriminatorFragments.push('body');
            }
            if (relation.conditionalComments) {
                Array.prototype.push.apply(discriminatorFragments, _.pluck(relation.conditionalComments, 'nodeValue'));
            }
            if (relation.type === 'HtmlStyle') {
                discriminatorFragments.push(relation.node.getAttribute('media') || 'all');
                for (i = 0 ; i < relation.node.attributes.length ; i += 1) {
                    attribute = relation.node.attributes[i];
                    if (attribute.name !== 'media' &&
                        (attribute.name !== 'rel' || attribute.value !== 'stylesheet') &&
                        (attribute.name !== 'href' || relation.node.nodeName.toLowerCase() !== 'link') &&
                        (attribute.name !== 'type' || attribute.value !== 'text/css' || !relation.to || relation.to.type !== 'Css')) {
                        return 'nobundle';
                    }
                }
            } else if (relation.type === 'HtmlScript') {
                if (relation.to.strict) {
                    discriminatorFragments.push('strict');
                    var warning = new Error('Global "use strict"-directive. Splitting into multiple bundles to avoid side effects.');
                    warning.asset = relation.to;
                    assetGraph.emit('info', warning);
                }
                if (relation.node.getAttribute('defer') === 'defer') {
{'fraction_non_alphanumeric': 0.12406716417910447, 'fraction_numerical': 0.0007462686567164179, 'mean_word_length': 1.6565906838453914, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '226270', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1285, 'n_words': 249}