Comparing version 1.1.0 to 1.2.0
@@ -38,2 +38,3 @@ /** | ||
var onlySplit = options.onlySplit || false; | ||
var alwaysWriteScript = options.alwaysWriteScript || false; | ||
@@ -64,3 +65,3 @@ var doc = dom5.parse(source); | ||
if (!onlySplit) { | ||
if (contents.length > 0) { | ||
if (contents.length > 0 || alwaysWriteScript) { | ||
var newScript = dom5.constructors.element('script'); | ||
@@ -67,0 +68,0 @@ dom5.setAttribute(newScript, 'src', jsFileName); |
{ | ||
"name": "crisper", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Make an HTML file with inline scripts CSP compliant", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -19,6 +19,8 @@ # Crisper | ||
file | ||
- `--always-write-script`: Always create a .js file, even without any `<script>` | ||
elements. | ||
Library usage: | ||
var output = crisp({ | ||
var output = crisper({ | ||
source: 'source HTML string', | ||
@@ -34,3 +36,3 @@ jsFileName: 'output js file name.js', | ||
var output = crisp.split('source HTML string', 'output js filename.js'); | ||
var output = crisper.split('source HTML string', 'output js filename.js'); | ||
@@ -65,3 +67,3 @@ ## Usage with Vulcanize | ||
- [gulp-crisper](https://npmjs.com/package/gulp-crisper) | ||
- *No grunt plugin yet, will you write it?* | ||
- [grunt-crisper](https://www.npmjs.com/package/grunt-crisper) | ||
- *No broccoli plugin yet, will you write it?* |
@@ -78,2 +78,27 @@ /** | ||
suite('No JS produces empty script when forced', function() { | ||
var obj; | ||
setup(function() { | ||
obj = crisp({ | ||
source: '<body>Hello World</body>', | ||
jsFileName: 'foo.js', | ||
alwaysWriteScript: true | ||
}); | ||
}); | ||
test('js property is the empty string', function() { | ||
assert.ok(obj.js === ""); | ||
}); | ||
test('output js is linked via <script> in the output html <body>', function() { | ||
var doc = dom5.parse(obj.html); | ||
var outscript = dom5.query(doc, pred.AND( | ||
pred.hasTagName('script'), | ||
pred.hasAttrValue('src', 'foo.js') | ||
)); | ||
assert.ok(outscript); | ||
}); | ||
}); | ||
suite('script defer\'d in head', function() { | ||
@@ -80,0 +105,0 @@ var obj; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17149
253
67
1