Skip to content

Commit

Permalink
Merge pull request #5 from uzairfarooq/dev
Browse files Browse the repository at this point in the history
Release v1.1.1 (bug fixes)
  • Loading branch information
uzairfarooq committed Apr 16, 2014
2 parents 5e7986e + 1c30aef commit 56dee08
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

arrive.js provides events to watch for DOM elements creation and removal. It makes use of [Mutation Observers](https://developer.mozilla.org/en/docs/Web/API/MutationObserver) internally.

[Download arrive-1.1.min.js](https://raw.githubusercontent.com/uzairfarooq/arrive/master/releases/arrive-1.1.min.js) (latest)
[Download arrive-1.1.1.min.js](https://raw.githubusercontent.com/uzairfarooq/arrive/master/releases/arrive-1.1.1.min.js) (latest)

## Usage
**The library does not depend on jQuery, you can replace jQuery elements in the examples below with pure javascript elements and it would work fine.**
Expand Down Expand Up @@ -51,7 +51,7 @@ $(document).unbindArrive(".test-elem", callbackFunc);
```
###Watch for elements removal
Use `leave` event to watch for elements removal.
The first arugument to leave must not be a [descendent] (https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_selectors) or [child] (https://developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors) selector i.e. you cannot pass `.page .test-elem`, instead, pass `.test-elem`. It's because of a limitation in MutationObserver's api.
The first arugument to leave must not be a [descendent](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_selectors) or [child](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_selectors) selector i.e. you cannot pass `.page .test-elem`, instead, pass `.test-elem`. It's because of a limitation in MutationObserver's api.

```javascript
// watch for removal of an element which satisfies the selector ".test-elem"
Expand All @@ -75,7 +75,7 @@ arrive.js is built over [Mutation Observers](https://developer.mozilla.org/en/do

##Contributing
####Report a bug / Request a feature
If you want to report a bug or request a feature, use the [Issues] (https://github.com/uzairfarooq/arrive/issues) section. Before creating a new issue, search the existing ones to make sure that you're not creating a duplicate. When reporting a bug, be sure to include OS/browser version and steps/code to reproduce the bug, a [JSFiddle] (http://jsfiddle.net/) would be great.
If you want to report a bug or request a feature, use the [Issues](https://github.com/uzairfarooq/arrive/issues) section. Before creating a new issue, search the existing ones to make sure that you're not creating a duplicate. When reporting a bug, be sure to include OS/browser version and steps/code to reproduce the bug, a [JSFiddle](http://jsfiddle.net/) would be great.

####Development
If you want ot contribute to arrive here is the workflow you should use:
Expand Down
16 changes: 16 additions & 0 deletions releases/arrive-1.1.1.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/arrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/*
* arrive.js
* v1.1
* v1.1.1
* https://github.com/uzairfarooq/arrive
* MIT licensed
*
Expand Down Expand Up @@ -99,7 +99,7 @@

// mutation observer does not work on window or document
if (target === window.document || target === window)
target = document.body.parentNode;
target = document.getElementsByTagName("html")[0];

// Create an observer instance
observer = new MutationObserver(function(e) {
Expand All @@ -117,7 +117,7 @@
});

function toArray(elements) {
if (elements instanceof HTMLElement || elements instanceof HTMLDocument || elements instanceof Window) {
if (elements[0] === undefined) {
elements = [elements];
}
return elements;
Expand Down Expand Up @@ -281,6 +281,8 @@
exposeApi($.fn);
}
exposeApi(HTMLElement.prototype);
exposeApi(NodeList.prototype);
exposeApi(HTMLCollection.prototype);
exposeApi(HTMLDocument.prototype);
exposeApi(Window.prototype);

Expand Down
12 changes: 12 additions & 0 deletions tests/spec/arriveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,17 @@ describe("Arrive", function() {
});

});

describe("Calling arrive function on NodeList and HTMLElement", function() {
it("arrive function should be callable on NodeList", function() {
document.getElementsByTagName("body").arrive(".test", function() {});
expect(true).toBeTruthy();
});

it("arrive function should be callable on HTMLElement", function() {
document.getElementsByTagName("body")[0].arrive(".test", function() {});
expect(true).toBeTruthy();
});
});
});
});

0 comments on commit 56dee08

Please sign in to comment.