html-janitor
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,2 +5,10 @@ # HTML Janitor | ||
## 1.1.0 | ||
It should be possible to allow all attributes on an element. This was mentioned in the documentation but was not working as intended. | ||
As the previous behaviour was broken I don't believe anyone was using it but if you were then hopefully it will just magically work for you now. | ||
Thanks [Alex Palaistras](https://github.com/deuill) for fixing this. | ||
## 1.0.1 | ||
@@ -7,0 +15,0 @@ |
@@ -13,3 +13,4 @@ require({ | ||
p.setAttribute('bar', 'baz'); | ||
p.setAttribute('foo', 'fighter'); | ||
console.log(janitor.clean(p.outerHTML)); | ||
}); |
{ | ||
"name": "html-janitor", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"main": "src/html-janitor.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -12,3 +12,3 @@ # html-janitor | ||
``` | ||
var janitor = HTMLJanitor(options); | ||
var janitor = new HTMLJanitor(options); | ||
@@ -50,2 +50,2 @@ var sanitisedHtml = janitor.clean(html); | ||
npm run test | ||
``` | ||
``` |
@@ -114,3 +114,3 @@ (function (root, factory) { | ||
// Allow attribute? | ||
var allowedAttrValue = allowedAttrs[attrName]; | ||
var allowedAttrValue = allowedAttrs[attrName] || allowedAttrs === true; | ||
var notInAttrList = ! allowedAttrValue; | ||
@@ -117,0 +117,0 @@ var valueNotAllowed = allowedAttrValue !== true && attr.value !== allowedAttrValue; |
@@ -22,2 +22,3 @@ define([ 'html-janitor' ], function (HTMLJanitor) { | ||
li: {}, | ||
small: true, | ||
div: {} | ||
@@ -145,2 +146,25 @@ } | ||
it('should allow all attributes for elements with catch-all whitelist', function () { | ||
var el = document.createElement('small'); | ||
el.setAttribute('data-test', 'true'); | ||
el.setAttribute('title', 'test'); | ||
var outputEl = document.createElement('div'); | ||
outputEl.innerHTML = janitor.clean(el.outerHTML); | ||
var output = outputEl.children[0]; | ||
expect(output.tagName).toBe('SMALL'); | ||
var attributes = output.attributes; | ||
expect(attributes.getNamedItem('data-test').name).toBe('data-test'); | ||
expect(attributes.getNamedItem('data-test').value).toBe('true'); | ||
expect(attributes.getNamedItem('title').name).toBe('title'); | ||
expect(attributes.getNamedItem('title').value).toBe('test'); | ||
}); | ||
}); | ||
@@ -147,0 +171,0 @@ |
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
28399
363
50