Skip to content

Commit 5071e54

Browse files
committed
OptionToNumber method refactored:
- Removed option type validation - Renamed into getOptionValue as it can be used for any option types
1 parent dde585c commit 5071e54

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

lib/web/mage/sticky.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,12 @@ define([
1717
stickyClass: '_sticky'
1818
},
1919

20-
_optionToNumber: function (option) {
20+
_getOptionValue: function (option) {
2121
var value = this.options[option] || 0;
2222
if (typeof value === 'function') {
2323
value = this.options[option]();
2424
}
25-
26-
var converted = Number(value);
27-
if (isNaN(converted)) {
28-
throw Error(
29-
'sticky: Could not convert supplied option "' +
30-
option + '" to Number from "' + value + '"'
31-
);
32-
}
33-
return converted;
25+
return value;
3426
},
3527

3628
/**
@@ -61,13 +53,13 @@ define([
6153
if (!isStatic && this.element.is(':visible')) {
6254
offset = $(document).scrollTop()
6355
- this.parentOffset
64-
+ this._optionToNumber('spacingTop');
56+
+ this._getOptionValue('spacingTop');
6557

6658
offset = Math.max(0, Math.min(offset, this.maxOffset));
6759

6860
var stuck = this.element.hasClass(this.options.stickyClass);
6961
if (offset && this.options.offsetTop && !stuck) {
70-
var offsetTop = this._optionToNumber('offsetTop');
62+
var offsetTop = this._getOptionValue('offsetTop');
7163
if (offset < offsetTop) {
7264
offset = 0;
7365
}

0 commit comments

Comments
 (0)