Skip to content

Commit 8196416

Browse files
committed
Removed unneeded code from $.fn.removeProp().
Added documentation for $.fn.removeProp() and $.fn.val().
1 parent b6158d3 commit 8196416

File tree

11 files changed

+91
-30
lines changed

11 files changed

+91
-30
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ A lightweight modular jQuery clone/alternative library built for modern browsers
44

55
![Licence](https://img.shields.io/badge/Licence-MIT-lightgrey.svg)
66
![Project Status](https://img.shields.io/badge/Project%20Status-Beta-yellow.svg)
7-
![Size Minified](https://img.shields.io/badge/Size%20(Minified)-16.3kb-brightgreen.svg)
8-
![Size Gzipped](https://img.shields.io/badge/Size%20(Gzipped)-6.01kb-brightgreen.svg)
7+
![Size Minified](https://img.shields.io/badge/Size%20(Minified)-16.5kb-brightgreen.svg)
8+
![Size Gzipped](https://img.shields.io/badge/Size%20(Gzipped)-6.05kb-brightgreen.svg)
99

1010
**This project is now in beta, make sure to test your integration with this code thoroughly before deploying**
1111

dist/dabby.es5.js

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dabby.es5.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dabby.es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dabby.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -865,15 +865,13 @@ $.fn.prop = function (prop, value) {
865865
};
866866

867867
$.fn.removeProp = function (prop) {
868-
if (this[0]) {
869-
let i = this.length;
870-
prop = getProp(prop);
868+
let i = this.length;
869+
prop = getProp(prop);
871870

872-
while (i--) {
873-
delete this[i][prop];
874-
}
875-
return this;
871+
while (i--) {
872+
delete this[i][prop];
876873
}
874+
return this;
877875
};
878876

879877
$.fn.map = function (callback) {

dist/dabby.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ The library supports the following methods:
3333
| [$.fn.css()](../src/attributes/css/readme.md) | Get/set CSS attributes |
3434
| [$.fn.data()](../src/attributes/data/readme.md) | Get/set data attributes |
3535
| [$.fn.prop()](../src/attributes/prop/readme.md) | Get/set properties |
36-
| $.fn.removeProp() | Remove the selected property |
37-
| $.fn.val() | Get/set form control values |
36+
| [$.fn.removeProp()](../src/attributes/removeprop/readme.md)| Remove the selected property |
37+
| [$.fn.val()](../src/attributes/val/readme.md) | Get/set form control values |
3838
| [$.fn.addClass()](../src/attributes/class/readme.md) | Add a class to elements in a collection |
3939
| [$.fn.hasClass()](../src/attributes/hasclass/readme.md) | See whether any elements in a collection have the requested class |
4040
| [$.fn.removeClass()](../src/attributes/class/readme.md) | Remove a class from an HTML element |

src/attributes/attr/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A plain object of key / value pairs representing the attributes to set.
2525

2626
### function
2727

28-
A callback that receives the index of the element in the collection, and the current value of the attrivute. Should return the new attribute value. `this` will reference the current item in the collection that is being processed.
28+
A callback that receives the index of the element in the collection, and the current value of the attribute. Should return the new attribute value. `this` will reference the current item in the collection that is being processed.
2929

3030
## Returns
3131

src/attributes/removeprop/readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# .removeProp()
2+
3+
Remove the selected property from all objects in a collection.
4+
5+
## Usage
6+
7+
```javascript
8+
$(selector).removeProp(propertyName);
9+
```
10+
11+
**It is recommended that you only use this method to remove custom properties, as removing native elements from DOM objects or the `window` object may cause a browser error**
12+
13+
#### propertyName
14+
15+
The name of the property you wish to remove.
16+
17+
## Returns
18+
19+
The original Dabby collection.
20+
21+
## Differences to jQuery
22+
23+
None.

src/attributes/removeprop/removeprop.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import $ from "../../core/core.js";
22
import getProp from "../../internal/getprop/getprop.js";
33

44
$.fn.removeProp = function (prop) {
5-
if (this[0]) {
6-
let i = this.length;
7-
prop = getProp(prop);
5+
let i = this.length;
6+
prop = getProp(prop);
87

9-
while (i--) {
10-
delete this[i][prop];
11-
}
12-
return this;
8+
while (i--) {
9+
delete this[i][prop];
1310
}
11+
return this;
1412
};

0 commit comments

Comments
 (0)