Does JSLint parse DOM functions?
Posted
by Paul
on Stack Overflow
See other posts from Stack Overflow
or by Paul
Published on 2010-06-12T07:44:54Z
Indexed on
2010/06/12
7:52 UTC
Read the original article
Hit count: 229
JavaScript
|jslint
I tried to use the parse() function of JSLint to parse three pieces of JavaScript code:
- function(b, c){var a = b + c; return a; }
- window.addEventListener('click', click_hanlder, true);
- document.documentElement.innerHTML;
Here's the code, which is copied and pasted from the JSLint self-parse example: ` try { parse = make_parse();
var source = "something to parse";//replaced by the code above
tree = parse(source);
if (tree) {
document.write(JSON.stringify(tree, ['key', 'name', 'message',
'value', 'arity', 'first', 'second', 'third', 'fourth'], 4));
}
} catch (e) { document.write(JSON.stringify(e, ['name', 'message', 'from', 'to', 'key', 'value', 'arity', 'first', 'second', 'third', 'fourth'], 4)); } `
The output:
- returns a correct tree.
- returns a tree with only one node of "window".
- crashes the browser.
I'm wondering whether JSLint doesn't support DOM function.
© Stack Overflow or respective owner