<commit_before>'use strict';

module.exports = function generateCode(node, codegen, vdomUtil) {
    var context = codegen.context;
    var builder = codegen.builder;

    // node.name = codegen.generateCode(node.name);
    node.value = codegen.generateCode(node.value);
    node.isStatic = vdomUtil.isStaticValue(node.value);

    var name = node.name;

    if (node.value && node.value.type !== 'Literal') {
        if (name === 'class') {
            node.value = builder.functionCall(context.helper('classAttr'), [node.value]);
        } else if (name === 'style') {
            node.value = builder.functionCall(context.helper('styleAttr'), [node.value]);
        }
    }

    return node;
};<commit_msg>Additional fixes for #386 - Allow regular expression for an HTML attribute value<commit_after>'use strict';

module.exports = function generateCode(node, codegen, vdomUtil) {
    var context = codegen.context;
    var builder = codegen.builder;

    // node.name = codegen.generateCode(node.name);
    node.value = codegen.generateCode(node.value);
    node.isStatic = vdomUtil.isStaticValue(node.value);
    var name = node.name;

    var attrValue = node.value;

    if (attrValue) {
        if (attrValue.type === 'Literal') {
            var literalValue = attrValue.value;

            if (literalValue instanceof RegExp) {
                node.value = builder.literal(literalValue.source);
            }
        } else {
            if (name === 'class') {
                node.value = builder.functionCall(context.helper('classAttr'), [attrValue]);
            } else if (name === 'style') {
                node.value = builder.functionCall(context.helper('styleAttr'), [attrValue]);
            }
        }
    }

    return node;
};
{'fraction_non_alphanumeric': 0.13657142857142857, 'fraction_numerical': 0.0017142857142857142, 'mean_word_length': 2.5589430894308944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1553966', 'n_tokens_mistral': 511, 'n_tokens_neox': 494, 'n_words': 107}