- All Implemented Interfaces:
- CompilerPass
class ReplaceCssNames
extends java.lang.Object
implements CompilerPass
ReplaceCssNames replaces occurrences of goog.getCssName('foo') with
a shorter version from the passed in renaming map. There are two
styles of operation: for 'BY_WHOLE' we look up the whole string in the
renaming map. For 'BY_PART', all the class name's components,
separated by '-', are renamed individually and then recombined.
Given the renaming map:
{
once: 'a',
upon: 'b',
atime: 'c',
long: 'd',
time: 'e',
ago: 'f'
}
The following outputs are expected with the 'BY_PART' renaming style:
goog.getCssName('once') -> 'a'
goog.getCssName('once-upon-atime') -> 'a-b-c'
var baseClass = goog.getCssName('long-time');
el.className = goog.getCssName(baseClass, 'ago');
->
var baseClass = 'd-e';
el.className = baseClass + '-f';
However if we have the following renaming map with the 'BY_WHOLE' renaming style:
{
once: 'a',
upon-atime: 'b',
long-time: 'c',
ago: 'd'
}
Then we would expect:
goog.getCssName('once') -> 'a'
var baseClass = goog.getCssName('long-time');
el.className = goog.getCssName(baseClass, 'ago');
->
var baseClass = 'c';
el.className = baseClass + '-d';
In addition, the CSS names before replacement can optionally be gathered.