Skip to content

Commit

Permalink
fix: remove data- from search attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Aug 13, 2021
1 parent 6598c69 commit a2285a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
name="selectField4"
placeholder="Single Options">

<input class="search-options" placeholder="Search" data-search_id="search_01" data-item_selector=".option">
<input placeholder="Search" search_id="search_01" search-selector=".option">

<ul class="options overflow:overlay" data-search_id="search_01">
<ul class="options overflow:overlay" search_id="search_01">
<li class="option" data-value="value 1">
<h3 >vale 1</h3>
<h3 >value11</h3>
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const CoCreateSearch = {
return;
}

let search_elements = mainContainer.querySelectorAll('.search-options')
let search_elements = mainContainer.querySelectorAll('[search-selector]')
const self = this;
search_elements.forEach(element => {
self.searchEvent(element)
Expand All @@ -22,14 +22,14 @@ const CoCreateSearch = {
},

runSearchOfElement: function(searchElement, value) {
const search_id = searchElement.getAttribute('data-search_id')
const item_selector = searchElement.getAttribute('data-item_selector')
const search_id = searchElement.getAttribute('search_id')
const item_selector = searchElement.getAttribute('search-selector')

if (!search_id || !item_selector) {
return;
}

const items = document.querySelectorAll(`[data-search_id='${search_id}'] ${item_selector}`)
const items = document.querySelectorAll(`[search_id='${search_id}'] ${item_selector}`)

items.forEach((item) => {
const textContent = item.innerText
Expand Down

0 comments on commit a2285a9

Please sign in to comment.