Comparing version 1.0.5 to 1.0.6
@@ -35,3 +35,2 @@ /** | ||
var doc = dom5.parse(source); | ||
var head = dom5.query(doc, pred.hasTagName('head')); | ||
var body = dom5.query(doc, pred.hasTagName('body')); | ||
@@ -58,5 +57,7 @@ var scripts = dom5.queryAll(doc, inlineScriptFinder); | ||
var newScript = dom5.constructors.element('script'); | ||
dom5.setAttribute(newScript, 'src', jsFileName); | ||
dom5.append(body, newScript); | ||
if (contents.length > 0) { | ||
var newScript = dom5.constructors.element('script'); | ||
dom5.setAttribute(newScript, 'src', jsFileName); | ||
dom5.append(body, newScript); | ||
} | ||
@@ -63,0 +64,0 @@ var html = dom5.serialize(doc); |
{ | ||
"name": "crisper", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Make an HTML file with inline scripts CSP compliant", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,25 +20,48 @@ /** | ||
suite('Split API', function() { | ||
var obj; | ||
setup(function() { | ||
obj = crisp.split('', 'foo.js'); | ||
}); | ||
suite('Default', function () { | ||
var obj; | ||
setup(function() { | ||
obj = crisp.split('<script>var foo = "bar";</script>', 'foo.js'); | ||
}); | ||
test('return object with js and html properties', function() { | ||
assert.property(obj, 'html'); | ||
assert.property(obj, 'js'); | ||
}); | ||
test('return object with js and html properties', function() { | ||
assert.property(obj, 'html'); | ||
assert.property(obj, 'js'); | ||
}); | ||
test('output html is serialized', function() { | ||
assert.typeOf(obj.html, 'string'); | ||
test('output html is serialized', function() { | ||
assert.typeOf(obj.html, 'string'); | ||
}); | ||
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); | ||
}); | ||
}); | ||
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('No JS', function() { | ||
var obj; | ||
setup(function() { | ||
obj = crisp.split('<body>Hello World</body>', 'foo.js'); | ||
}); | ||
test('js property is empty', function() { | ||
assert.notOk(obj.js); | ||
}); | ||
test('output js is NOT 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.notOk(outscript); | ||
}); | ||
}); | ||
}); | ||
@@ -45,0 +68,0 @@ |
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
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
13154
168