Skip to content

Commit b6da30b

Browse files
author
Graham Butler
committed
fix showBySelector behavior
1 parent 7ba96d9 commit b6da30b

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@author.io/element-cycle",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "author-cycle custom element (web component).",
55
"main": "dist/author-cycle.min.js",
66
"scripts": {

showroom/src/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ <h2 class="hidden">Navigation</h2>
3939
</author-control>
4040

4141
<author-cycle>
42-
<section selected>
42+
<section class="first" selected>
4343
<h2>Section 1</h2>
4444

4545
<p>
4646
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
4747
</p>
48+
49+
<p class="test">
50+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
51+
</p>
4852
</section>
4953

50-
<section>
54+
<section class="second">
5155
<h2>Section 2</h2>
5256

5357
<p>
@@ -59,7 +63,7 @@ <h2>Section 2</h2>
5963
</p>
6064
</section>
6165

62-
<section>
66+
<section class="third">
6367
<h2>Section 3</h2>
6468

6569
<p>

src/element.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class AuthorCycleElement extends AuthorBaseElement(HTMLElement) {
155155
},
156156

157157
showChildBySelector: query => {
158-
let nodes = this.querySelectorAll(query)
158+
let nodes = [...this.children].filter(child => child.matches(query))
159159

160160
if (!nodes.length) {
161161
return this.UTIL.printToConsole(`Node matching query "${query}" not found. Aborting...`, 'warning')
@@ -164,8 +164,8 @@ class AuthorCycleElement extends AuthorBaseElement(HTMLElement) {
164164
if (nodes.length > 1) {
165165
this.UTIL.printToConsole(`Found multiple nodes matching "${query}". Displaying first result...`, 'warning')
166166
}
167-
168-
this.PRIVATE.showChild(nodes.item(0))
167+
168+
this.PRIVATE.showChild(nodes[0])
169169
}
170170
})
171171

0 commit comments

Comments
 (0)