Skip to content

Commit

Permalink
Use exact match on classList instead of regex on className to check f…
Browse files Browse the repository at this point in the history
…or CSS classes
  • Loading branch information
carter-thaxton committed Sep 11, 2016
1 parent 1261e7e commit f52b782
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions example.html
Expand Up @@ -149,19 +149,19 @@ <h2>Known limitations</h2>
<script>
function setupSlip(list) {
list.addEventListener('slip:beforereorder', function(e){
if (/demo-no-reorder/.test(e.target.className)) {
if (e.target.classList.indexOf('demo-no-reorder') >= 0) {
e.preventDefault();
}
}, false);

list.addEventListener('slip:beforeswipe', function(e){
if (e.target.nodeName == 'INPUT' || /demo-no-swipe/.test(e.target.className)) {
if (e.target.nodeName == 'INPUT' || e.target.classList.indexOf('demo-no-swipe') >= 0) {
e.preventDefault();
}
}, false);

list.addEventListener('slip:beforewait', function(e){
if (e.target.className.indexOf('instant') > -1) e.preventDefault();
if (e.target.classList.indexOf('instant') >= 0) e.preventDefault();
}, false);

list.addEventListener('slip:afterswipe', function(e){
Expand Down
4 changes: 2 additions & 2 deletions testDetach.html
Expand Up @@ -124,7 +124,7 @@ <h1>Slip.js</h1>
<script src="slip.js"></script>
<script>
function beforereorder(e) {
if (/demo-no-reorder/.test(e.target.className)) {
if (e.target.classList.indexOf('demo-no-reorder') >= 0) {
e.preventDefault();
}
}
Expand All @@ -145,7 +145,7 @@ <h1>Slip.js</h1>
function Attach(e) {
e.target.removeEventListener('click', Attach, false);
document.demo1SlipObj = setupSlip(document.getElementById('demo1'));

document.getElementById("detach").addEventListener('click', Detach, false);
}

Expand Down

0 comments on commit f52b782

Please sign in to comment.