Skip to content

Commit 5f5571a

Browse files
committed
Fixed #350
1 parent eb0f1d0 commit 5f5571a

11 files changed

+76
-41
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ Bower users can install all compiled and minified files easily using `bower inst
1212

1313
Changelog
1414
---------
15-
###7.0.4 ~ 7.0.6
15+
###7.0.8
16+
+ Fixed an issue in the way the `$.fn.val` method is overridden. (#350)
17+
18+
###7.0.4 ~ 7.0.7
1619
+ Bower support.
1720

1821
###7.0.3:

distribute/jquery.nouislider.all.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! noUiSlider - 7.0.6 - 2014-09-11 20:29:06 */
1+
/*! noUiSlider - 7.0.8 - 2014-09-24 14:32:09 */
22

33
(function(){
44

@@ -2019,35 +2019,44 @@ function closure ( target, options, originalOptions ){
20192019
// the slider value handling. No? Use the standard method.
20202020
// Note how $.fn.val expects 'this' to be an instance of $. For convenience,
20212021
// the above 'value' function does too.
2022-
$.fn.val = function ( ) {
2022+
$.fn.val = function ( arg ) {
20232023

20242024
// this === instanceof $
20252025

20262026
function valMethod( a ){
20272027
return a.hasClass(Classes[0]) ? value : $val;
20282028
}
20292029

2030-
var args = arguments,
2031-
first = $(this[0]);
2032-
2033-
if ( !arguments.length ) {
2030+
// If no value is passed, this is 'get'.
2031+
if ( arg === undefined ) {
2032+
var first = $(this[0]);
20342033
return valMethod(first).call(first);
20352034
}
20362035

2037-
// Return the set so it remains chainable
2038-
return this.each(function(){
2039-
valMethod($(this)).apply($(this), args);
2036+
var isFunction = $.isFunction(arg);
2037+
2038+
// Return the set so it remains chainable. Make sure not to break
2039+
// jQuery's .val(function( index, value ){}) signature.
2040+
return this.each(function( i ){
2041+
2042+
var val = arg, $t = $(this);
2043+
2044+
if ( isFunction ) {
2045+
val = arg.call(this, i, $t.val());
2046+
}
2047+
2048+
valMethod($t).call($t, val);
20402049
});
20412050
};
20422051

20432052
// Extend jQuery/Zepto with the noUiSlider method.
20442053
$.fn.noUiSlider = function ( options, rebuildFlag ) {
2045-
2054+
20462055
switch ( options ) {
20472056
case 'step': return this[0].getCurrentStep();
20482057
case 'options': return this[0].getOriginalOptions();
20492058
}
2050-
2059+
20512060
return ( rebuildFlag ? rebuild : initialize ).call(this, options);
20522061
};
20532062

distribute/jquery.nouislider.all.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distribute/jquery.nouislider.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! noUiSlider - 7.0.6 - 2014-09-11 20:29:06 */
1+
/*! noUiSlider - 7.0.8 - 2014-09-24 14:32:09 */
22

33
/*jslint browser: true */
44
/*jslint white: true */
@@ -1371,35 +1371,44 @@ function closure ( target, options, originalOptions ){
13711371
// the slider value handling. No? Use the standard method.
13721372
// Note how $.fn.val expects 'this' to be an instance of $. For convenience,
13731373
// the above 'value' function does too.
1374-
$.fn.val = function ( ) {
1374+
$.fn.val = function ( arg ) {
13751375

13761376
// this === instanceof $
13771377

13781378
function valMethod( a ){
13791379
return a.hasClass(Classes[0]) ? value : $val;
13801380
}
13811381

1382-
var args = arguments,
1383-
first = $(this[0]);
1384-
1385-
if ( !arguments.length ) {
1382+
// If no value is passed, this is 'get'.
1383+
if ( arg === undefined ) {
1384+
var first = $(this[0]);
13861385
return valMethod(first).call(first);
13871386
}
13881387

1389-
// Return the set so it remains chainable
1390-
return this.each(function(){
1391-
valMethod($(this)).apply($(this), args);
1388+
var isFunction = $.isFunction(arg);
1389+
1390+
// Return the set so it remains chainable. Make sure not to break
1391+
// jQuery's .val(function( index, value ){}) signature.
1392+
return this.each(function( i ){
1393+
1394+
var val = arg, $t = $(this);
1395+
1396+
if ( isFunction ) {
1397+
val = arg.call(this, i, $t.val());
1398+
}
1399+
1400+
valMethod($t).call($t, val);
13921401
});
13931402
};
13941403

13951404
// Extend jQuery/Zepto with the noUiSlider method.
13961405
$.fn.noUiSlider = function ( options, rebuildFlag ) {
1397-
1406+
13981407
switch ( options ) {
13991408
case 'step': return this[0].getCurrentStep();
14001409
case 'options': return this[0].getOriginalOptions();
14011410
}
1402-
1411+
14031412
return ( rebuildFlag ? rebuild : initialize ).call(this, options);
14041413
};
14051414

distribute/jquery.nouislider.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distribute/jquery.nouislider.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

distribute/jquery.nouislider.pips.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nouislider.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"url": "http://www.wtfpl.net/"
1717
}
1818
],
19-
"version": "7.0.6",
19+
"version": "7.0.8",
2020
"author": {
2121
"name": "Léon Gersen",
2222
"url": "https://twitter.com/LeonGersen"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "noUiSlider",
3-
"version": "7.0.6",
3+
"version": "7.0.8",
44
"devDependencies": {
55
"grunt": "~0.4.1",
66
"grunt-contrib-compress": "^0.11.0",

src/js/interface.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,43 @@
5757
// the slider value handling. No? Use the standard method.
5858
// Note how $.fn.val expects 'this' to be an instance of $. For convenience,
5959
// the above 'value' function does too.
60-
$.fn.val = function ( ) {
60+
$.fn.val = function ( arg ) {
6161

6262
// this === instanceof $
6363

6464
function valMethod( a ){
6565
return a.hasClass(Classes[0]) ? value : $val;
6666
}
6767

68-
var args = arguments,
69-
first = $(this[0]);
70-
71-
if ( !arguments.length ) {
68+
// If no value is passed, this is 'get'.
69+
if ( arg === undefined ) {
70+
var first = $(this[0]);
7271
return valMethod(first).call(first);
7372
}
7473

75-
// Return the set so it remains chainable
76-
return this.each(function(){
77-
valMethod($(this)).apply($(this), args);
74+
var isFunction = $.isFunction(arg);
75+
76+
// Return the set so it remains chainable. Make sure not to break
77+
// jQuery's .val(function( index, value ){}) signature.
78+
return this.each(function( i ){
79+
80+
var val = arg, $t = $(this);
81+
82+
if ( isFunction ) {
83+
val = arg.call(this, i, $t.val());
84+
}
85+
86+
valMethod($t).call($t, val);
7887
});
7988
};
8089

8190
// Extend jQuery/Zepto with the noUiSlider method.
8291
$.fn.noUiSlider = function ( options, rebuildFlag ) {
83-
92+
8493
switch ( options ) {
8594
case 'step': return this[0].getCurrentStep();
8695
case 'options': return this[0].getOriginalOptions();
8796
}
88-
97+
8998
return ( rebuildFlag ? rebuild : initialize ).call(this, options);
9099
};

0 commit comments

Comments
 (0)