Skip to content

Commit

Permalink
fix: correct the type of the value argument in the filter() function
Browse files Browse the repository at this point in the history
  • Loading branch information
webdiscus committed Oct 17, 2023
1 parent 6fca8a6 commit 532acf7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change log

## 2.14.5 (2023-10-17)

- fix: correct the type of the `value` argument in the `filter()` function of the `sources` loader option

## 2.14.4 (2023-10-12)

- fix: correct attributes type in the `filter()` function of the `sources` loader option
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ type Sources =
filter?: (props: {
tag: string;
attribute: string;
value: string;
value: string | Array<string>;
attributes: { [k: string]: string };
resourcePath: string;
}) => boolean | undefined;
Expand Down Expand Up @@ -2071,7 +2071,7 @@ The argument is an object containing the properties:
- `tag: string` - a name of the HTML tag
- `attribute: string` - a name of the HTML attribute
- `value: string` - a value of the HTML attribute
- `value: string | Array<string>` - a value of the HTML attribute; for `srcset` the value is an array of parsed filenames
- `attributes: string` - all attributes of the tag
- `resourcePath: string` - a path of the HTML template
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-bundler-webpack-plugin",
"version": "2.14.4",
"version": "2.14.5",
"description": "HTML bundler plugin for webpack handles a template as an entry point, extracts CSS and JS from their sources referenced in HTML, supports template engines like Eta, EJS, Handlebars, Nunjucks.",
"keywords": [
"html",
Expand Down
11 changes: 10 additions & 1 deletion test/cases/loader-option-sources-attrs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,16 @@ module.exports = {
tag: 'img-ng',
attributes: ['data-src-one', 'data-src-two'],
},

// TODO: in next major version
// - change the value as original string
// - add the values argument containing array of parsed in srcset filenames
// {
// tag: 'img',
// attributes: ['srcset'],
// filter: ({ attribute, value, values }) => {
// console.log('\n### ATTR: ', { attribute, value, values });
// },
// },
{
tag: 'link',
attributes: ['data-source'],
Expand Down
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ type Sources =
filter?: (props: {
tag: string;
attribute: string;
value: string;
value: string | Array<string>;
attributes: { [k: string]: string };
resourcePath: string;
}) => boolean | undefined;
Expand Down

0 comments on commit 532acf7

Please sign in to comment.