Skip to content

Commit

Permalink
Remove replaceAll polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
wbamberg committed Jun 22, 2022
1 parent 8f619c5 commit 69c852a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions kumascript/macros/CSSSyntax.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
const webRefData = require('@webref/css');
const { definitionSyntax } = require('css-tree');
const replaceAll = require('string.prototype.replaceall');
const locale = env.locale;
Expand Down Expand Up @@ -125,17 +124,18 @@ function renderNode(name, node) {
}
case 'Type': {
// encode < and >
let encoded = replaceAll(name, '<', '&lt;');
encoded = replaceAll(encoded, '>', '&gt;');
let encoded = name.replaceAll('<', '&lt;');
encoded = encoded.replaceAll('>', '&gt;');
// add CSS class: we use "property" because there isn't one for types
const span = `<span class="token property">${encoded}</span>`;
// if this type is not included in the syntax, link to its dedicated page
if (valuespaces[name] && valuespaces[name].value) {
return span;
} else {
// the slug does not include the angle brackets
let slug = replaceAll(name, '<', '');
slug = replaceAll(slug, '>', '');
let slug = name.replaceAll('<', '');
slug = slug.replaceAll('>', '');
// also remove the range in square brackets, as in "<number [0,∞]>"
slug = slug.replace(/\[.*\]/, '')
return `<a href="/${locale}/docs/Web/CSS/${slug}">${span}</a>`;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ function renderNode(name, node) {
if (node.combinator && (node.combinator !== ' ')) {
const info = syntaxDescriptions[node.combinator];
// note that we are replacing the combinator surrounded by spaces, like " | "
name = replaceAll(name, ` ${node.combinator} `, ` <a href="${valueDefinitionUrl}#${info.fragment}" title="${info.tooltip}">${node.combinator}</a> `);
name = name.replaceAll(` ${node.combinator} `, ` <a href="${valueDefinitionUrl}#${info.fragment}" title="${info.tooltip}">${node.combinator}</a> `);
}
return name;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@
"semver": "^7.3.5",
"source-map-explorer": "^2.5.2",
"source-map-loader": "^3.0.0",
"string.prototype.replaceall": "^1.0.6",
"style-dictionary": "^3.7.1",
"style-loader": "^3.3.1",
"stylelint": "^13.13.1",
Expand Down

0 comments on commit 69c852a

Please sign in to comment.