From 7309734dbf52e0e9d9682ad563660a5d0acb51de Mon Sep 17 00:00:00 2001 From: RubaXa Date: Wed, 11 Mar 2015 18:06:34 +0300 Subject: [PATCH] #290: + clone simple 'option' and 'extend' method --- Sortable.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sortable.js b/Sortable.js index 9bdc895..db894b6 100644 --- a/Sortable.js +++ b/Sortable.js @@ -165,7 +165,7 @@ */ function Sortable(el, options) { this.el = el; // root element - this.options = options = (options || {}); + this.options = options = _extend({}, options); // Default options @@ -1017,6 +1017,18 @@ }; } + function _extend(dst, src) { + if (dst && src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + dst[key] = src[key]; + } + } + } + + return dst; + } + // Export utils Sortable.utils = { @@ -1028,6 +1040,7 @@ is: function (el, selector) { return !!_closest(el, selector, el); }, + extend: _extend, throttle: _throttle, closest: _closest, toggleClass: _toggleClass,