fix #60 typings

This commit is contained in:
Zongmin Lei
2016-12-02 10:53:59 +08:00
parent 821474541a
commit 6313322abd
3 changed files with 25 additions and 4 deletions

7
typings/tsconfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"compilerOptions": {
"strictNullChecks": true,
"noImplicitAny": true,
"module": "commonjs"
}
}

View File

@@ -23,6 +23,20 @@ console.log(xss('hello', {
css: false,
}));
xss('hello');
xss('hello', {
escapeHtml(str) {
return str.trim();
},
stripBlankChar: true,
onTag(tag, html, options) {
return html;
},
onIgnoreTag(tag, html) {
},
});
interface ICustomWhiteList extends XSS.IWhiteList {
view?: string[];

8
typings/xss.d.ts vendored
View File

@@ -86,9 +86,9 @@ declare namespace XSS {
video?: string[];
}
export type OnTagHandler = (tag: string, html: string, options: {}) => string;
export type OnTagHandler = (tag: string, html: string, options: {}) => string | void;
export type OnTagAttrHandler = (tag: string, name: string, value: string) => string;
export type OnTagAttrHandler = (tag: string, name: string, value: string) => string | void;
export type SafeAttrValueHandler = (tag: string, name: string, value: string, cssFilter: ICSSFilter) => string;
@@ -106,7 +106,7 @@ declare module 'xss' {
onIgnoreTag(tag: string, html: string, options: {
position: number;
isClosing: boolean;
});
}): string;
remove(html: string): string;
};
@@ -119,7 +119,7 @@ declare module 'xss' {
(html: string, options?: XSS.IFilterXSSOptions): string;
FilterXSS: typeof FilterXSS;
parseTag(html: string, onTag: (sourcePosition: number, position: number, tag: string, html: string, isClosing: boolean) => string, escapeHtml: EscapeHandler): string;
parseTag(html: string, onTag: (sourcePosition: number, position: number, tag: string, html: string, isClosing: boolean) => string, escapeHtml: XSS.EscapeHandler): string;
parseAttr(html: string, onAttr: (name: string, value: string) => string): string;
whiteList: XSS.IWhiteList;
getDefaultWhiteList(): XSS.IWhiteList;