Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor refactor to .eq method #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
recusandae suscipit repellendus placeat necessitatibus blanditiis aspernatur! Debitis voluptas officiis,
voluptate, mollitia dolore distinctio! Sed.</p>
</div>
<script src="../package/dom7.umd.js"></script>
<script src="../package/dom7.js"></script>
<script>
var $ = window.Dom7;
</script>
Expand Down
15 changes: 4 additions & 11 deletions src/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,19 +562,12 @@ function index() {
}
return undefined;
}

function eq(index) {
if (typeof index === 'undefined') return this;
const length = this.length;
if (index > length - 1) {
return $([]);
}
if (index < 0) {
const returnIndex = length + index;
if (returnIndex < 0) return $([]);
return $([this[returnIndex]]);
}
return $([this[index]]);
if (index === undefined) return this;
return $(index < 0 ? this[index += this.length] : this[index]);
}

function append(...els) {
let newChild;
const document = getDocument();
Expand Down