Skip to content

Commit

Permalink
Fix validateSelector method stopped working if a selector could not b…
Browse files Browse the repository at this point in the history
…e validated
  • Loading branch information
bfiessinger committed Mar 12, 2021
1 parent b109322 commit 872191a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 16 deletions.
5 changes: 5 additions & 0 deletions changelog.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 3.0.1 (Hotfix release)

#### Bug Fixes
- ScrollToSmooth stopped working in version 3.0.0 when the selector to be validated would fail

### 3.0.0

#### Features
Expand Down
13 changes: 10 additions & 3 deletions dist/scrolltosmooth.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,16 @@ var forEach = function forEach(arr, callback) {

var validateSelector = function validateSelector(selector) {
var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : d;
var valid = false; // Check if the target is a valid selector inside the scrollToSmooth container
var valid = true; // Check if the target is a valid selector inside the scrollToSmooth container

if (typeof selector == 'string' && _$(selector, container) || isNodeOrElement(selector) && container.contains(selector)) {
valid = true;
try {
if (typeof selector === 'string') {
_$(selector, container);
} else if (isNodeOrElement(selector) && container.contains(selector)) {
selector;
}
} catch (e) {
valid = false;
}

return valid;
Expand Down Expand Up @@ -747,6 +753,7 @@ function getTargetElement(el) {
return this.container;
}

console.log(targetSelector, validateSelector(targetSelector, this.container));
return validateSelector(targetSelector, this.container) ? _$(targetSelector, this.container) : null;
}
/**
Expand Down
13 changes: 10 additions & 3 deletions dist/scrolltosmooth.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,16 @@ var forEach = function forEach(arr, callback) {

var validateSelector = function validateSelector(selector) {
var container = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : d;
var valid = false; // Check if the target is a valid selector inside the scrollToSmooth container
var valid = true; // Check if the target is a valid selector inside the scrollToSmooth container

if (typeof selector == 'string' && _$(selector, container) || isNodeOrElement(selector) && container.contains(selector)) {
valid = true;
try {
if (typeof selector === 'string') {
_$(selector, container);
} else if (isNodeOrElement(selector) && container.contains(selector)) {
selector;
}
} catch (e) {
valid = false;
}

return valid;
Expand Down Expand Up @@ -743,6 +749,7 @@ function getTargetElement(el) {
return this.container;
}

console.log(targetSelector, validateSelector(targetSelector, this.container));
return validateSelector(targetSelector, this.container) ? _$(targetSelector, this.container) : null;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion dist/scrolltosmooth.min.js

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

Loading

0 comments on commit 872191a

Please sign in to comment.