Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ module.exports = function(content) {
}
var root = config.root;
var links = attrParse(content, function(tag, attr) {
var item = tag + ":" + attr;
var res = attributes.find(function(a) {
return item.indexOf(a) >= 0;
if (a.charAt(0) === ':') {
return attr === a.slice(1);
} else {
return (tag + ":" + attr) === a;
}
});
return !!res;
});
Expand Down
7 changes: 7 additions & 0 deletions test/loaderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ describe("loader", function() {
'module.exports = "Text <custom-element custom-src=\\"" + require("./image1.png") + "\\"><custom-img custom-src=\\"" + require("./image2.png") + "\\"/></custom-element>";'
);
});
it("should accept :attribute (empty tag) from query and not collide with similar attributes", function() {
loader.call({
query: "?attrs[]=:custom-src"
}, 'Text <custom-element custom-src="image1.png" custom-src-other="other.png"><custom-img custom-src="image2.png"/></custom-element>').should.be.eql(
'module.exports = "Text <custom-element custom-src=\\"" + require("./image1.png") + "\\" custom-src-other=\\"other.png\\"><custom-img custom-src=\\"" + require("./image2.png") + "\\"/></custom-element>";'
);
});
it("should not make bad things with templates", function() {
loader.call({}, '<h3>#{number} {customer}</h3>\n<p> {title} </p>').should.be.eql(
'module.exports = "<h3>#{number} {customer}</h3>\\n<p> {title} </p>";'
Expand Down