Sha256: 670e64395c878d9c66a2882a793c33b619feed6a221e41b6dfce578b8d002e94
Contents?: true
Size: 1.42 KB
Versions: 19
Compression:
Stored size: 1.42 KB
Contents
/** * class CharsetNormalizer * * Some browsers have issues with stylesheets that contain multiple * `@charset` definitions. The `CharsetNormalizer` processor strips * out multiple `@charset` definitions. * * The current implementation is naive. It picks the first `@charset` * it sees and strips the others. This works for most people because * the other definitions are usually `UTF-8`. A more sophisticated * approach would be to re-encode stylesheets with mixed encodings. * * This behavior can be disabled with: * * environment.unregisterBundleProcessor('text/css', CharsetNormalizer); * * * ##### SUBCLASS OF * * [[Template]] **/ 'use strict'; // internal var Template = require('../template'); //////////////////////////////////////////////////////////////////////////////// // Class constructor var CharsetNormalizer = module.exports = function CharsetNormalizer() { Template.apply(this, arguments); }; require('util').inherits(CharsetNormalizer, Template); // Cached version of RegExp used to find and process charset directives var CHARSET_RE = /^@charset "([^"]+)";$/gm; // Process data CharsetNormalizer.prototype.evaluate = function (/*context, locals*/) { var charset = null; this.data = this.data.replace(CHARSET_RE, function (m) { charset = charset || m; return ''; }); if (null !== charset) { this.data = charset + '\n' + this.data; } return this.data; };
Version data entries
19 entries across 19 versions & 1 rubygems