Skip to content

Commit e36d401

Browse files
authored
Merge pull request #77 from AegisJSProject/patch/updates
Misc updates
2 parents b5d239a + 375d806 commit e36d401

File tree

6 files changed

+35
-18
lines changed

6 files changed

+35
-18
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [v0.0.16] - 2024-11-26
11+
12+
### Changed
13+
- Update `@aegisjsproject/url`
14+
- Add `sync` option when creating CSS parsers (controls use of `sheet.replace` vs `sheet.replaceSync`)
15+
1016
## [v0.0.15] - 2024-11-09
1117

1218
### Added

css.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,24 @@ export function createStyleSheet(cssRules, { media, disabled, baseURL } = {}) {
3737
baseURL
3838
});
3939

40-
sheet.replace(cssRules).catch(console.error);
40+
sheet.replace(cssRules).catch(reportError);
4141
return sheet;
4242
}
4343

44-
export const createCSSParser = ({ media, disabled, baseURL } = {}) => (strings, ...args) => {
45-
return createStyleSheet(String.raw(strings, ...args.map(stringify)).trim(), { media, disabled, baseURL });
46-
};
44+
export function createStyleSheetSync(cssRules, { media, disabled, baseURL } = {}) {
45+
const sheet = new CSSStyleSheet({
46+
media: media instanceof MediaQueryList ? media.media : media,
47+
disabled,
48+
baseURL
49+
});
50+
51+
sheet.replaceSync(cssRules);
52+
return sheet;
53+
}
54+
55+
export const createCSSParser = ({ media, disabled, baseURL, sync = false } = {}) => sync
56+
? (strings, ...args) => createStyleSheetSync(String.raw(strings, ...args.map(stringify)).trim(), { media, disabled, baseURL })
57+
: (strings, ...args) => createStyleSheet(String.raw(strings, ...args.map(stringify)).trim(), { media, disabled, baseURL });
4758

4859
export const css = createCSSParser();
4960

package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aegisjsproject/parsers",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"description": "A collection of secure & minimal parsers for HTML, CSS, SVG, MathML, XML, and JSON",
55
"keywords": [
66
"aegis",
@@ -78,7 +78,7 @@
7878
}
7979
],
8080
"bugs": {
81-
"url": "https://github.com/./issues"
81+
"url": "https://github.com/AegisJSProject/parsers/issues"
8282
},
8383
"homepage": "https://github.com/AegisJSProject/parsers#readme",
8484
"devDependencies": {
@@ -91,6 +91,6 @@
9191
},
9292
"dependencies": {
9393
"@aegisjsproject/sanitizer": "^0.1.3",
94-
"@aegisjsproject/url": "^1.0.0"
94+
"@aegisjsproject/url": "^1.0.1"
9595
}
9696
}

rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default [{
99
'@aegisjsproject/sanitizer/config/mathml.js',
1010
'@aegisjsproject/sanitizer/config/base.js',
1111
'@aegisjsproject/sanitizer/namespaces.js',
12-
'@aegisjsproject/url/url.js',
12+
'@aegisjsproject/url/parser.js',
1313
],
1414
output: {
1515
file: 'parsers.cjs',

url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { escape, url } from '@aegisjsproject/url/url.js';
1+
export { url, escape, createURLParser } from '@aegisjsproject/url/parser.js';

0 commit comments

Comments
 (0)