Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

Commit 96e04b8

Browse files
committedMar 2, 2016
Version bump
- Fix jhamlet#15: No need to eval single attribute. - Loader utils already JSON parses the query string for us. - New test for JSON query strings
1 parent 4151a50 commit 96e04b8

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed
 

‎index.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,12 @@ module.exports = function (source) {
7575
var displayName = params.name || getName(rsrcPath);
7676
var tag = params.tag || null;
7777
var reactDom = params.reactDom || 'react-dom';
78-
var attrs = {};
79-
80-
if (params.attrs) {
81-
// easier than having to write json in the query
82-
// if anyone wants to exploit it, it's their build process
83-
/*eslint no-eval:0*/
84-
eval('assign(attrs, ' + params.attrs + ');');
85-
}
78+
var attrs = assign({}, params.attrs || {});
8679

8780
var opts = {
88-
reactDom: reactDom,
89-
tagName: tag,
90-
attrs: attrs,
81+
reactDom: reactDom,
82+
tagName: tag,
83+
attrs: attrs,
9184
displayName: displayName
9285
};
9386

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svg-react-loader",
33
"fullname": "SVG to React Loader",
44
"description": "A Webpack Loader to turn SVGs into React Components",
5-
"version": "0.3.2",
5+
"version": "0.3.3",
66
"keywords": [
77
"webpack",
88
"loader",

‎test/test-test.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*globals describe, it*/
22
var react = require('react');
3-
var loader = require('svg-react-loader');
3+
var loader = require('../');
44
var babel = require('babel-core');
55
var fs = require('fs');
66
var path = require('path');
@@ -33,7 +33,7 @@ function read (filepath) {
3333
return fs.readFileSync(path.join(__dirname, filepath), 'utf8');
3434
}
3535

36-
describe('something', function () {
36+
describe('svg-react-loader', function () {
3737
it('should return a function', function () {
3838
loader.should.be.a.function;
3939
});
@@ -113,4 +113,28 @@ describe('something', function () {
113113
resourcePath: filename
114114
});
115115
});
116+
117+
it('json query', function (done) {
118+
var filename = './svg/text.svg';
119+
120+
invoke(read(filename), {
121+
callback: function (/*error, result*/) {
122+
done();
123+
},
124+
query: '?' + JSON.stringify({
125+
attrs: {
126+
style: {},
127+
width: 'auto',
128+
height: 'auto'
129+
}
130+
}),
131+
resourceQuery: '?' + JSON.stringify({
132+
attrs: {
133+
style: {},
134+
width: 'auto',
135+
height: 'auto'
136+
}
137+
})
138+
});
139+
});
116140
});

0 commit comments

Comments
 (0)
Failed to load comments.