Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attr matching for empty tags in tag:attribute patterns #133

Merged
merged 1 commit into from
Aug 8, 2017

Conversation

nuragic
Copy link
Contributor

@nuragic nuragic commented Jul 17, 2017

As reported in #129 (comment) there was a bug in the previous implementation, so I've just fixed it and added a test to cover that case.

⚠️ Opening against master because there's no other branch apparently. However, as also reported in the above comment, people is looking at docs in README.md (and eventually the code) but their local version is not yet aligned because the code in master is not released, so it would be nice to create a dev branch. 😌

@michael-ciniawsky michael-ciniawsky changed the title Fix for the PR #129 fix: attr matching for empty tags in tag:attribute patterns Jul 17, 2017
@michael-ciniawsky michael-ciniawsky added this to the 0.4.6 milestone Jul 17, 2017
README.md Outdated
@@ -27,6 +27,20 @@ By default every local `<img src="image.png">` is required (`require('./image.pn

You can specify which tag-attribute combination should be processed by this loader via the query parameter `attrs`. Pass an array or a space-separated list of `<tag>:<attribute>` combinations. (Default: `attrs=img:src`)

If you use `<custom-elements>`, and lots of them make use of a `custom-src` attribute, you don't have to specify each combination `<tag>:<attribute>`: just specify an empty tag like `attrs=:custom-src` and it will match every element.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Necessary to document both ways ? (honestly 😛 ) :attr && tag:attr ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky Hi! Sorry but I'm not sure that I'm understanding what should be changed here... please could you clarify? Thanks!

@michael-ciniawsky
Copy link
Member

Could you also rebase against latest master ? Why is it even outdated 🙃 :)

index.js Outdated
var res = attributes.find(function(a) {
return item.indexOf(a) >= 0;
if (a.startsWith(':')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky ⚠️ FYI startsWith method has been introduced in ES6 so... not sure if it's ok or I should replace it with the corresponding ES5 version ...

Copy link
Member

@michael-ciniawsky michael-ciniawsky Jul 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node >= v4 Support ? What is the alternative ? I'm working on #134 which is v1.0.0 with min node >= v4. It would normally be good to stay with node >= v0.12 in the current semver minor range, but node >= v0.12 is EOL and eventually the next release includes #134 anyways 😛 but not 💯 sure yet.

const starts = (value, str) => str.substr(0, value.length) === value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, just checked on node.green. Supported on Node >= v4 (the v0.12 requires the --harmony flag... 😅 No worries, in this case a.charAt(0) === ':' is exactly the same so changing it right now. 😉

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or str.charCodeAt(0) === ':' || str[0] === ':' yep 😛

@codecov
Copy link

codecov bot commented Jul 18, 2017

Codecov Report

Merging #133 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
+ Coverage    96.9%   96.93%   +0.03%     
==========================================
  Files           2        2              
  Lines          97       98       +1     
  Branches       18       19       +1     
==========================================
+ Hits           94       95       +1     
  Misses          3        3
Impacted Files Coverage Δ
index.js 96.59% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e9bce2...ea095e3. Read the comment docs.

@andersevenrud
Copy link

Looks like you need to rebase :) What are the release schedules, anyway ? I'd love to have this in an official relase.

@hemanth
Copy link
Contributor

hemanth commented Aug 1, 2017

We can schedule a release soon after this PR.

@nuragic
Copy link
Contributor Author

nuragic commented Aug 3, 2017

@andersevenrud Uhm... weird... it was up to date...

@hemanth did someone git push -f on master? I've 35 commits now on this PR :feelsgood:

(Rebased BTW).

@nuragic nuragic force-pushed the nuragic-proposal-fix branch from 69e84c7 to ea095e3 Compare August 3, 2017 06:43
@joshwiens joshwiens merged commit 6efa6de into webpack-contrib:master Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants