read css escapes per spec

This commit is contained in:
tophf 2021-04-20 20:27:07 +03:00
parent f10ebffeff
commit 0aa6d3b463
4 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,7 @@
html#stylus #header *:not(#\0transition-suppressor) {
html#stylus #header *:not(#\1transition-suppressor) {
/* This suppresses a bug in all? browsers: they apply transitions during page load.
* Using an increased specificity to override sane selectors in user styles. */
* Using an increased specificity to override sane selectors in user styles.
* Using \1 to simplify js code because \0 is converted to \xFFFD per spec. */
transition: none !important;
}
body {

View File

@ -3014,8 +3014,14 @@ self.parserlib = (() => {
}
readEscape() {
const cp = this._reader.readMatch(/[0-9a-f]{1,6}\b\s*/iy);
return cp ? String.fromCodePoint(parseInt(cp, 16)) : this._reader.read();
let res = this._reader.readMatch(/[0-9a-f]{1,6}\s?/iy);
if (res) {
res = parseInt(res, 16);
res = String.fromCodePoint(res && res <= 0x10FFFF ? res : 0xFFFD);
} else {
res = this._reader.read();
}
return res;
}
/**

View File

@ -440,8 +440,7 @@ async function waitForSheet({
window.on('load', () => {
const {sheet} = $('link[href^="global.css"]');
for (let i = 0, rule; (rule = sheet.cssRules[i]); i++) {
// Not using \0 in the id as it's converted to \xFFFD, probably a bug
if (/#.transition-suppressor/.test(rule.selectorText)) {
if (/#\\1\s?transition-suppressor/.test(rule.selectorText)) {
sheet.deleteRule(i);
break;
}

View File

@ -7,7 +7,7 @@ testGlobalCss();
function testGlobalCss() {
const css = fs.readFileSync('global.css', {encoding: 'utf8'});
const ERR = 'global.css: missing the transition suppressor rule';
const RX_SUPPRESSOR = /[^{}]+#\\0transition-suppressor[^{}]+{\s*transition:\s*none\s*!\s*important/i;
const RX_SUPPRESSOR = /[^{}]+#\\1\s?transition-suppressor[^{}]+{\s*transition:\s*none\s*!\s*important/i;
const RX_COMMENT = /\/\*([^*]|\*(?!\/))*(\*\/|$)/g;
if (!RX_SUPPRESSOR.test(css.replace(RX_COMMENT, ''))) {
console.error(ERR);