const rcs = require('rcs-core')
rcs.fillLibraries(fs.readFileSync('./test.html', 'utf8'),{codeType: 'html'});
console.log(rcs.mapping.generate())
rcs.optimize();
const test = rcs.replace.html(fs.readFileSync('./test.html', 'utf8'));
// output some warnings which has been stacked through the process
rcs.warnings.warn();
fs.writeFileSync('./dist/rcs_test.html', test);
fillLibrary does not make a mapping for overlay-symbol id, I think this is because there is no actual rule on the style section.
replace is replacing getElementById("overlay-symbol") with its mapping for the class overlay-symbol. Now, given that optimize utilizes the same letters for ids and classes, they collide on the script section when they get replaced.
I understand that the first problem could be rather an implementation decision: only automatically map selectors present on css rules. Although, ids and classes can also de used as means for javascript to interact with html elements.
The second issue I take as the actual bug, I think it should not replace an id string for a class string.
Although probably this is not a breaking problem if I provide my own mapping file.
Hi! I found the following issue that I tried to track down into this example:
I run
rcs
with the following script:The result:
The mappings generated by
optimize
:There are two things happening here:
fillLibrary
does not make a mapping foroverlay-symbol
id, I think this is because there is no actual rule on thestyle
section.replace
is replacinggetElementById("overlay-symbol")
with its mapping for the classoverlay-symbol
. Now, given thatoptimize
utilizes the same letters for ids and classes, they collide on thescript
section when they get replaced.I understand that the first problem could be rather an implementation decision: only automatically map selectors present on css rules. Although, ids and classes can also de used as means for javascript to interact with html elements.
The second issue I take as the actual bug, I think it should not replace an id string for a class string.
Although probably this is not a breaking problem if I provide my own mapping file.
Thanks for the module!