Skip to content

Commit a738928

Browse files
committed
Remove jscdoc
1 parent e934afa commit a738928

File tree

3 files changed

+37
-124
lines changed

3 files changed

+37
-124
lines changed

index.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2015 Titus Wormer
4-
* @license MIT
5-
* @module hdast:sanitize
6-
* @fileoverview Sanitize HAST.
7-
*/
8-
91
'use strict';
10-
11-
/* Expose. */
122
module.exports = require('./lib/index');

lib/index.js

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2015 Titus Wormer
4-
* @license MIT
5-
* @module hdast:sanitize
6-
* @fileoverview Sanitize HAST.
7-
*/
8-
91
'use strict';
102

113
/* Dependencies. */
@@ -31,14 +23,7 @@ var NODES = {
3123
}
3224
};
3325

34-
/**
35-
* Sanitize `node`, according to `schema`.
36-
*
37-
* @param {Node} node - HAST node to sanitize.
38-
* @param {Object} [schema] - Schema to use.
39-
* Defaults to `github`.
40-
* @return {Node} - Sanitized HAST node.
41-
*/
26+
/* Sanitize `node`, according to `schema`. */
4227
function wrapper(node, schema) {
4328
var ctx = {type: 'root', children: []};
4429
var replace;
@@ -66,14 +51,7 @@ function wrapper(node, schema) {
6651
return replace;
6752
}
6853

69-
/**
70-
* Sanitize `node`.
71-
*
72-
* @param {Object} schema - Configuration.
73-
* @param {Node} node - HAST node to sanitize.
74-
* @param {Array.<string>} stack - Element stack.
75-
* @return {Node?|Array.<Node>} - Clean node(s).
76-
*/
54+
/* Sanitize `node`. */
7755
function one(schema, node, stack) {
7856
var type = node && node.type;
7957
var replacement = {type: node.type};
@@ -116,15 +94,7 @@ function one(schema, node, stack) {
11694
return replacement;
11795
}
11896

119-
/**
120-
* Sanitize `children`.
121-
*
122-
* @param {Object} schema - Configuration.
123-
* @param {Array.<Node>} children - HAST nodes.
124-
* @param {Node} node - Parent.
125-
* @param {Array.<string>} stack - Element stack.
126-
* @return {Array.<Node>} - Clean nodes.
127-
*/
97+
/* Sanitize `children`. */
12898
function all(schema, children, node, stack) {
12999
var nodes = children || [];
130100
var length = nodes.length || 0;
@@ -149,15 +119,7 @@ function all(schema, children, node, stack) {
149119
return results;
150120
}
151121

152-
/**
153-
* Sanitize `properties`.
154-
*
155-
* @param {Object} schema - Configuration.
156-
* @param {Object} properties - Element `properties`.
157-
* @param {Node} node - Context.
158-
* @param {Array.<string>} stack - Element stack.
159-
* @return {Object} - Clean properties.
160-
*/
122+
/* Sanitize `properties`. */
161123
function handleProperties(schema, properties, node, stack) {
162124
var name = handleTagName(schema, node.tagName, node, stack);
163125
var attrs = schema.attributes;
@@ -194,14 +156,7 @@ function handleProperties(schema, properties, node, stack) {
194156
return result;
195157
}
196158

197-
/**
198-
* Sanitize a property value which is a list.
199-
*
200-
* @param {Object} schema - Configuration.
201-
* @param {Array.<*>} values - List of values.
202-
* @param {string} prop - Key at which `values` live.
203-
* @return {Array.<number|boolean|string>} - Clean values.
204-
*/
159+
/* Sanitize a property value which is a list. */
205160
function handlePropertyValues(schema, values, prop) {
206161
var length = values.length;
207162
var result = [];
@@ -219,14 +174,7 @@ function handlePropertyValues(schema, values, prop) {
219174
return result;
220175
}
221176

222-
/**
223-
* Sanitize a property value.
224-
*
225-
* @param {Object} schema - Configuration.
226-
* @param {*} value - Value.
227-
* @param {string} prop - Key at which `value` live.
228-
* @return {number|boolean|string?} - Clean value.
229-
*/
177+
/* Sanitize a property value. */
230178
function handlePropertyValue(schema, value, prop) {
231179
if (
232180
typeof value !== 'boolean' &&
@@ -247,14 +195,7 @@ function handlePropertyValue(schema, value, prop) {
247195
return value;
248196
}
249197

250-
/**
251-
* Check whether `value` is a safe URL.
252-
*
253-
* @param {Object} schema - Configuration.
254-
* @param {*} value - Value.
255-
* @param {string} prop - Key at which `value` live.
256-
* @return {boolean} - Whether `value` is safe.
257-
*/
198+
/* Check whether `value` is a safe URL. */
258199
function handleProtocol(schema, value, prop) {
259200
var protocols = schema.protocols;
260201
var protocol;
@@ -311,17 +252,7 @@ function handleProtocol(schema, value, prop) {
311252
return false;
312253
}
313254

314-
/**
315-
* Sanitize `tagName`.
316-
*
317-
* @param {Object} schema - Configuration.
318-
* @param {*} tagName - Tag-name of element.
319-
* @param {Node} node - HAST node to sanitize.
320-
* @param {Array.<string>} stack - Element stack.
321-
* @return {string|boolean?} - `false`, if `tagName`
322-
* represents an unsage element, a string to use
323-
* as a tag-name otherwise.
324-
*/
255+
/* Sanitize `tagName`. */
325256
function handleTagName(schema, tagName, node, stack) {
326257
var name = typeof tagName === 'string' ? tagName : null;
327258
var ancestors = schema.ancestors;

test.js

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2016 Titus Wormer
4-
* @license MIT
5-
* @module hast-util-sanitize
6-
* @fileoverview Test suite for `hast-util-sanitize`.
7-
*/
8-
91
'use strict';
102

113
/* Dependencies. */
@@ -19,35 +11,6 @@ var sanitize = require('./index.js');
1911

2012
/* eslint-disable no-script-url, max-params */
2113

22-
/* Check */
23-
function toString() {
24-
return 'alert(1);';
25-
}
26-
27-
/* Coverage. */
28-
toString();
29-
30-
/* Test `valid` `url`s in `prop` on `tagName`. */
31-
function testURLs(t, tagName, prop, urls, valid) {
32-
Object.keys(urls).forEach(function (name) {
33-
var props = {};
34-
35-
props[prop] = urls[name];
36-
37-
t.deepEqual(
38-
sanitize(h(tagName, props)),
39-
h(tagName, valid ? props : {}),
40-
'should ' + (valid ? 'allow' : 'clean') + ' ' + name
41-
);
42-
});
43-
}
44-
45-
/* Test `valid` and `invalid` `url`s in `prop` on `tagName`. */
46-
function testAllURLs(t, tagName, prop, all) {
47-
testURLs(t, tagName, prop, all.valid, true);
48-
testURLs(t, tagName, prop, all.invalid, false);
49-
}
50-
5114
/* Tests. */
5215
test('sanitize()', function (t) {
5316
t.test('non-node', function (st) {
@@ -541,3 +504,32 @@ test('sanitize()', function (t) {
541504

542505
t.end();
543506
});
507+
508+
/* Coverage. */
509+
toString();
510+
511+
/* Check */
512+
function toString() {
513+
return 'alert(1);';
514+
}
515+
516+
/* Test `valid` and `invalid` `url`s in `prop` on `tagName`. */
517+
function testAllURLs(t, tagName, prop, all) {
518+
testURLs(t, tagName, prop, all.valid, true);
519+
testURLs(t, tagName, prop, all.invalid, false);
520+
}
521+
522+
/* Test `valid` `url`s in `prop` on `tagName`. */
523+
function testURLs(t, tagName, prop, urls, valid) {
524+
Object.keys(urls).forEach(function (name) {
525+
var props = {};
526+
527+
props[prop] = urls[name];
528+
529+
t.deepEqual(
530+
sanitize(h(tagName, props)),
531+
h(tagName, valid ? props : {}),
532+
'should ' + (valid ? 'allow' : 'clean') + ' ' + name
533+
);
534+
});
535+
}

0 commit comments

Comments
 (0)