From 6c89df429456856f520a4f23569aea706f560a1f Mon Sep 17 00:00:00 2001 From: Archie Lee Date: Fri, 9 Dec 2016 10:34:36 +0800 Subject: [PATCH 1/3] Add `css: false` --- index.js | 1 + test/fixtures/css.html | 19 +++++++++++++++++++ test/loader.spec.js | 14 ++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 test/fixtures/css.html diff --git a/index.js b/index.js index 10872dda..977a0c41 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,7 @@ module.exports = function(source, map) { filename: filename, format: query.format || 'es', name: query.name, + css: Boolean(query.css !== false), onerror: (err) => { console.log(err.message); this.emitError(err.message); diff --git a/test/fixtures/css.html b/test/fixtures/css.html new file mode 100644 index 00000000..95fe1ebd --- /dev/null +++ b/test/fixtures/css.html @@ -0,0 +1,19 @@ +

Count: {{count}}

+ +​ + + + \ No newline at end of file diff --git a/test/loader.spec.js b/test/loader.spec.js index fc0b0c2e..4467193e 100644 --- a/test/loader.spec.js +++ b/test/loader.spec.js @@ -100,6 +100,20 @@ describe('loader', function() { }, { format: 'umd', name: 'FooComponent' }) ); + it('should compile Component with css by default', + testLoader('test/fixtures/css.html', function(err, code, map) { + expect(err).not.to.exist; + expect(code).to.contain('if ( !addedCss ) addCss();'); + }) + ); + + it('should compile Component without css if requested', + testLoader('test/fixtures/css.html', function(err, code, map) { + expect(err).not.to.exist; + expect(code).not.to.contain('if ( !addedCss ) addCss();'); + }, { css: false }) + ); + }); From 95900294c7bcefcc4dfc50cc13302bfd9cdb9211 Mon Sep 17 00:00:00 2001 From: Archie Lee Date: Fri, 9 Dec 2016 10:37:19 +0800 Subject: [PATCH 2/3] Remove redundant word --- test/loader.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/loader.spec.js b/test/loader.spec.js index 4467193e..71f024db 100644 --- a/test/loader.spec.js +++ b/test/loader.spec.js @@ -72,7 +72,7 @@ describe('loader', function() { ); - it('should compile Component with with nesting', + it('should compile Component with nesting', testLoader('test/fixtures/parent.html', function(err, code, map) { expect(err).not.to.exist; From 4c06ceac7fc3952247a3d746302a4fc69662ee4f Mon Sep 17 00:00:00 2001 From: Archie Lee Date: Fri, 9 Dec 2016 16:21:34 +0800 Subject: [PATCH 3/3] Remove unnecessary Boolean construction --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 977a0c41..df2333df 100644 --- a/index.js +++ b/index.js @@ -13,7 +13,7 @@ module.exports = function(source, map) { filename: filename, format: query.format || 'es', name: query.name, - css: Boolean(query.css !== false), + css: query.css !== false, onerror: (err) => { console.log(err.message); this.emitError(err.message);