Skip to content

Commit

Permalink
Merge pull request #77 from AegisJSProject/patch/updates
Browse files Browse the repository at this point in the history
Misc updates
  • Loading branch information
shgysk8zer0 authored Nov 26, 2024
2 parents b5d239a + 375d806 commit e36d401
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v0.0.16] - 2024-11-26

### Changed
- Update `@aegisjsproject/url`
- Add `sync` option when creating CSS parsers (controls use of `sheet.replace` vs `sheet.replaceSync`)

## [v0.0.15] - 2024-11-09

### Added
Expand Down
19 changes: 15 additions & 4 deletions css.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@ export function createStyleSheet(cssRules, { media, disabled, baseURL } = {}) {
baseURL
});

sheet.replace(cssRules).catch(console.error);
sheet.replace(cssRules).catch(reportError);
return sheet;
}

export const createCSSParser = ({ media, disabled, baseURL } = {}) => (strings, ...args) => {
return createStyleSheet(String.raw(strings, ...args.map(stringify)).trim(), { media, disabled, baseURL });
};
export function createStyleSheetSync(cssRules, { media, disabled, baseURL } = {}) {
const sheet = new CSSStyleSheet({
media: media instanceof MediaQueryList ? media.media : media,
disabled,
baseURL
});

sheet.replaceSync(cssRules);
return sheet;
}

export const createCSSParser = ({ media, disabled, baseURL, sync = false } = {}) => sync
? (strings, ...args) => createStyleSheetSync(String.raw(strings, ...args.map(stringify)).trim(), { media, disabled, baseURL })
: (strings, ...args) => createStyleSheet(String.raw(strings, ...args.map(stringify)).trim(), { media, disabled, baseURL });

export const css = createCSSParser();

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aegisjsproject/parsers",
"version": "0.0.15",
"version": "0.0.16",
"description": "A collection of secure & minimal parsers for HTML, CSS, SVG, MathML, XML, and JSON",
"keywords": [
"aegis",
Expand Down Expand Up @@ -78,7 +78,7 @@
}
],
"bugs": {
"url": "https://github.com/./issues"
"url": "https://github.com/AegisJSProject/parsers/issues"
},
"homepage": "https://github.com/AegisJSProject/parsers#readme",
"devDependencies": {
Expand All @@ -91,6 +91,6 @@
},
"dependencies": {
"@aegisjsproject/sanitizer": "^0.1.3",
"@aegisjsproject/url": "^1.0.0"
"@aegisjsproject/url": "^1.0.1"
}
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default [{
'@aegisjsproject/sanitizer/config/mathml.js',
'@aegisjsproject/sanitizer/config/base.js',
'@aegisjsproject/sanitizer/namespaces.js',
'@aegisjsproject/url/url.js',
'@aegisjsproject/url/parser.js',
],
output: {
file: 'parsers.cjs',
Expand Down
2 changes: 1 addition & 1 deletion url.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { escape, url } from '@aegisjsproject/url/url.js';
export { url, escape, createURLParser } from '@aegisjsproject/url/parser.js';

0 comments on commit e36d401

Please sign in to comment.