UNPKG

@progress/kendo-ui

Version:

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

73 lines (66 loc) 1.92 kB
'use strict'; function applyKHeaderCompoundStrip(str) { let result = str; result = result.replace(/\.k-header(?=\.)/g, ''); result = result.replace(/(?<=[\w-])\.k-header/g, ''); return result; } function applyKPagerLgCompoundStrip(str) { let result = str; result = result.replace(/\.k-pager-lg(?=\.)/g, ''); result = result.replace(/(?<=[\w-])\.k-pager-lg/g, ''); return result; } function applyAll(str) { let result = str; result = applyKHeaderCompoundStrip(result); result = applyKPagerLgCompoundStrip(result); return result; } function transformStringLiterals(root, j, fn) { let changed = false; const visit = path => { if (typeof path.node.value !== 'string') { return; } const updated = fn(path.node.value); if (updated === path.node.value) { return; } path.node.value = updated; if (path.node.extra) { path.node.extra.rawValue = updated; if (path.node.extra.raw) { path.node.extra.raw = fn(path.node.extra.raw); } } changed = true; }; root.find(j.StringLiteral).forEach(visit); root.find(j.Literal, n => typeof n.value === 'string').forEach(visit); return changed; } function transformTemplateLiterals(root, j, fn) { let changed = false; root.find(j.TemplateLiteral).forEach(path => { path.node.quasis.forEach(quasi => { const updatedRaw = fn(quasi.value.raw); const updatedCooked = quasi.value.cooked != null ? fn(quasi.value.cooked) : null; if (updatedRaw !== quasi.value.raw || updatedCooked !== quasi.value.cooked) { quasi.value.raw = updatedRaw; if (quasi.value.cooked != null) { quasi.value.cooked = updatedCooked; } changed = true; } }); }); return changed; } module.exports = { applyKHeaderCompoundStrip, applyKPagerLgCompoundStrip, applyAll, transformStringLiterals, transformTemplateLiterals, };