UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

32 lines (24 loc) 863 B
'use strict'; const { ALL_CLASS_REPLACEMENTS, SCHEDULER_RE_CSS, applyClassReplacements, applySchedulerSelector } = require('../_shared.cjs'); function applyToStyleBlock(content) { let result = applyClassReplacements(content, ALL_CLASS_REPLACEMENTS); result = applySchedulerSelector(result, SCHEDULER_RE_CSS); return result; } const STYLE_RE = /(<style[^>]*>)([\s\S]*?)(<\/style>)/gi; module.exports = function transformer(fileInfo) { if (!/\.html?$/i.test(fileInfo.path)) { return undefined; } let source = fileInfo.source; let changed = false; source = source.replace(STYLE_RE, (match, open, content, close) => { const transformed = applyToStyleBlock(content); if (transformed !== content) { changed = true; return open + transformed + close; } return match; }); return changed ? source : undefined; };