google / google/closure-compiler

jQuery extern for attr(attributeName, value) should allow null for value

Open
#2,995 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

I'm using jQuery v3.3.1, with the externs in "contrib/externs/jquery-3.3.js". According to [the jQuery docs](http://api.jquery.com/attr/), this is valid:

```javascript
$("#foo").attr("bar", null); // equivalent to: $("#foo").removeAttr("bar");
```

When running google-closure-compiler with `--externs contrib/externs/jquery-3.3.js --compilation_level ADVANCED_OPTIMIZATIONS`, it reports:

```
WARNING - actual parameter 2 of jQuery.prototype.attr does not match formal parameter
found : null
required: (boolean|function(number, string): ?|number|string|undefined)
$("#foo").attr("bar", null);
^^^^
```

It looks like this might be as simple as adding `|null` to the extern, but it looks like this file might be auto-generated, and I'm not clear on some of the other types listed in this extern, so I don't feel I understand this line well enough to touch it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.