diff --git a/Sortable.js b/Sortable.js index e7bb2fe..c20e3be 100644 --- a/Sortable.js +++ b/Sortable.js @@ -889,6 +889,8 @@ el.removeEventListener(event, fn, false); } + /** @const */ + var RSPACE = /\s+/g; function _toggleClass(el, name, state) { if (el) { @@ -896,11 +898,8 @@ el.classList[state ? 'add' : 'remove'](name); } else { - var className = (' ' + el.className + ' ') - .replace(/\s+/g, ' ') - .replace(' ' + name + ' ', ' ') - .replace(/ /, ' '); - el.className = className + (state ? ' ' + name : ''); + var className = (' ' + el.className + ' ').replace(RSPACE, ' ').replace(' ' + name + ' ', ' '); + el.className = (className + (state ? ' ' + name : '')).replace(RSPACE, ' '); } } }