Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,6 @@ In the browser:
</script>
```

### Advanced Parsing

`parse()` can optionally accept a second parameter, an options object, which can be used to
modify parsing behavior.

The following options are recognized:
```JS
{
allowNestedTypedefs: false
}
```

And their meanings are as follows:

* `allowNestedTypedefs`: Boolean indicating whether the parser should accept `typedef`s as valid members of `interface`s.
This is non-standard syntax and therefore the default is `false`.

### Errors

When there is a syntax error in the WebIDL, it throws an exception object with the following
Expand Down
10 changes: 4 additions & 6 deletions lib/webidl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
}
}

function parse(tokens, opt) {
function parse(tokens) {
let line = 1;
tokens = tokens.slice();
const names = new Map();
Expand Down Expand Up @@ -656,8 +656,7 @@
ret.members.push(cnt);
continue;
}
const mem = (opt.allowNestedTypedefs && typedef()) ||
static_member() ||
const mem = static_member() ||
stringifier() ||
iterable() ||
attribute() ||
Expand Down Expand Up @@ -926,10 +925,9 @@
}

const obj = {
parse(str, opt) {
if (!opt) opt = {};
parse(str) {
const tokens = tokenise(str);
return parse(tokens, opt);
return parse(tokens);
}
};

Expand Down
3 changes: 0 additions & 3 deletions test/syntax/opt/typedef-nested.json

This file was deleted.