From 0ef326d9d29e36f80acf0a382dafa050a6c91abf Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Sat, 15 Jul 2017 20:56:30 +0200 Subject: [PATCH] chore(errors): move text into separate object and save some bytes approximately 100 bites can be made with something else now. Congratulations erryone --- js/holmes.es.js | 2 +- js/holmes.js | 2 +- js/main.js | 64 +++++++++++++++++++++++-------------------------- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/js/holmes.es.js b/js/holmes.es.js index d67bf93..f67f120 100644 --- a/js/holmes.es.js +++ b/js/holmes.es.js @@ -1 +1 @@ -var _global='undefined'==typeof window?global:window;function toFactory(f){var a=function(){for(var a,b=arguments.length,c=Array(b),d=0;dg.searchString.length||(g.options.dynamic&&(g.elements=document.querySelectorAll(g.options.find),g.elementsLength=g.elements.length,g.elementsArray=Array.prototype.slice.call(g.elements)),g.options.mark&&(g._regex=new RegExp('('+g.searchString+')(?![^<]*>)','gi')),g.elementsArray.forEach(function(a){stringIncludes(a.textContent.toLowerCase(),g.searchString)?(g._showElement(a),c&&'function'==typeof g.options.onFound&&g.options.onFound(g.placeholderNode),d=!0):g._hideElement(a)}),'function'==typeof g.options.onInput&&g.options.onInput(g.searchString),d?g.options.placeholder&&g._hideElement(g.placeholderNode):(g.options.placeholder&&g._showElement(g.placeholderNode),!1==c&&(c=!0,'function'==typeof g.options.onEmpty&&g.options.onEmpty(g.placeholderNode))))}}return createClass(f,[{key:'_hideElement',value:function(b){this.options.class.visible&&b.classList.remove(this.options.class.visible),b.classList.contains(this.options.class.hidden)||(b.classList.add(this.options.class.hidden),this.hidden++,'function'==typeof this.options.onHidden&&this.options.onHidden(b)),this.options.hiddenAttr&&b.setAttribute('hidden','true'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''))}},{key:'_showElement',value:function(b){this.options.class.visible&&b.classList.add(this.options.class.visible),b.classList.contains(this.options.class.hidden)&&(b.classList.remove(this.options.class.hidden),this.hidden--,'function'==typeof this.options.onVisible&&this.options.onVisible(b)),this.options.hiddenAttr&&b.removeAttribute('hidden'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''),this.searchString.length&&(b.innerHTML=b.innerHTML.replace(this._regex,'$1')))}},{key:'inputString',value:function(){if(this.input instanceof HTMLInputElement)return this.input.value.toLowerCase();if(this.input.contentEditable)return this.input.textContent.toLowerCase();throw new Error('The Holmes input was no or contenteditable.')}},{key:'setInput',value:function(b){if(this.input instanceof HTMLInputElement)this.input.value=b;else if(this.input.contentEditable)this.input.textContent=b;else throw new Error('The Holmes input was no or contenteditable.')}},{key:'start',value:function(){var d=document.querySelector(this.options.input);if(d instanceof HTMLElement)this.input=d;else throw new Error('Your Holmes.input didn\'t match a querySelector');if('string'==typeof this.options.find)this.elements=document.querySelectorAll(this.options.find);else throw new Error('A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like:\n\nnew Holmes({\n find:".result"\n});\n\nsee also https://haroen.me/holmes/doc/holmes.html');if(this.elementsLength=this.elements.length,this.elementsArray=Array.prototype.slice.call(this.elements),this.hidden=0,'string'==typeof this.options.placeholder){var a=this.options.placeholder;if(this.placeholderNode=document.createElement('div'),this.placeholderNode.id='holmes-placeholder',this._hideElement(this.placeholderNode),this.placeholderNode.innerHTML=a,this.elements[0].parentNode instanceof Element)this.elements[0].parentNode.appendChild(this.placeholderNode);else throw new Error('The Holmes placeholder couldn\'t be put; the elements had no parent.')}if(this.options.class.visible){var b=this.options.class.visible;this.elementsArray.forEach(function(c){c.classList.add(b)})}this.input.addEventListener('input',this._inputHandler)}},{key:'stop',value:function(){var d=this;return new Promise(function(a,b){try{d.input.removeEventListener('input',d._inputHandler),d.options.placeholder&&(d.placeholderNode.parentNode?d.placeholderNode.parentNode.removeChild(d.placeholderNode):b(new Error('The Holmes placeholderNode has no parent.'))),d.options.mark&&d.elementsArray.forEach(function(b){b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,'')}),d.running=!1,a('This instance of Holmes has been stopped.')}catch(c){b(c)}})}},{key:'clear',value:function(){var c=this;this.setInput(''),this.elementsArray.forEach(function(a){c._showElement(a)}),this.options.placeholder&&this._hideElement(this.placeholderNode),this.hidden=0}},{key:'count',value:function(){return{all:this.elementsLength,hidden:this.hidden,visible:this.elementsLength-this.hidden}}}]),f}(),holmes=toFactory(Holmes);export default holmes; +var _global='undefined'==typeof window?global:window;function toFactory(f){var a=function(){for(var a,b=arguments.length,c=Array(b),d=0;d or contenteditable.',optionsObject:'The options need to be given inside an object like this:\n\nnew Holmes({\n find:".result"\n});\n\nsee also https://haroen.me/holmes/doc/holmes.html',findOption:'A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like:\n\nnew Holmes({\n find:".result"\n});\n\nsee also https://haroen.me/holmes/doc/holmes.html',noInput:'Your Holmes.input didn\'t match a querySelector',impossiblePlaceholder:'The Holmes placeholder couldn\'t be put; the elements had no parent.'},Holmes=function(){function f(a){var g=this;classCallCheck(this,f);var c=!1;if('object'!==('undefined'==typeof a?'undefined':_typeof(a)))throw new Error(errors.optionsObject);if('string'!=typeof a.find)throw new Error(errors.findOption);var d={input:'input[type=search]',find:'',placeholder:void 0,mark:!1,class:{visible:void 0,hidden:'hidden'},dynamic:!1,minCharacters:0,hiddenAttr:!1,onHidden:void 0,onVisible:void 0,onEmpty:void 0,onFound:void 0,onInput:void 0};this.options=Object.assign({},d,a),this.options.class=Object.assign({},d.class,a.class),this.hidden=0,this.running=!1,window.addEventListener('DOMContentLoaded',function(){return g.start()}),this._inputHandler=function(){g.running=!0;var d=!1;g.searchString=g.inputString(),g.options.minCharacters&&0!==g.searchString.length&&g.options.minCharacters>g.searchString.length||(g.options.dynamic&&(g.elements=document.querySelectorAll(g.options.find),g.elementsLength=g.elements.length,g.elementsArray=Array.prototype.slice.call(g.elements)),g.options.mark&&(g._regex=new RegExp('('+g.searchString+')(?![^<]*>)','gi')),g.elementsArray.forEach(function(a){stringIncludes(a.textContent.toLowerCase(),g.searchString)?(g._showElement(a),c&&'function'==typeof g.options.onFound&&g.options.onFound(g.placeholderNode),d=!0):g._hideElement(a)}),'function'==typeof g.options.onInput&&g.options.onInput(g.searchString),d?g.options.placeholder&&g._hideElement(g.placeholderNode):(g.options.placeholder&&g._showElement(g.placeholderNode),!1==c&&(c=!0,'function'==typeof g.options.onEmpty&&g.options.onEmpty(g.placeholderNode))))}}return createClass(f,[{key:'_hideElement',value:function(b){this.options.class.visible&&b.classList.remove(this.options.class.visible),b.classList.contains(this.options.class.hidden)||(b.classList.add(this.options.class.hidden),this.hidden++,'function'==typeof this.options.onHidden&&this.options.onHidden(b)),this.options.hiddenAttr&&b.setAttribute('hidden','true'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''))}},{key:'_showElement',value:function(b){this.options.class.visible&&b.classList.add(this.options.class.visible),b.classList.contains(this.options.class.hidden)&&(b.classList.remove(this.options.class.hidden),this.hidden--,'function'==typeof this.options.onVisible&&this.options.onVisible(b)),this.options.hiddenAttr&&b.removeAttribute('hidden'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''),this.searchString.length&&(b.innerHTML=b.innerHTML.replace(this._regex,'$1')))}},{key:'inputString',value:function(){if(this.input instanceof HTMLInputElement)return this.input.value.toLowerCase();if(this.input.contentEditable)return this.input.textContent.toLowerCase();throw new Error(errors.invalidInput)}},{key:'setInput',value:function(b){if(this.input instanceof HTMLInputElement)this.input.value=b;else if(this.input.contentEditable)this.input.textContent=b;else throw new Error(errors.invalidInput)}},{key:'start',value:function(){var d=document.querySelector(this.options.input);if(d instanceof HTMLElement)this.input=d;else throw new Error(errors.noInput);if('string'==typeof this.options.find)this.elements=document.querySelectorAll(this.options.find);else throw new Error(errors.findOption);if(this.elementsLength=this.elements.length,this.elementsArray=Array.prototype.slice.call(this.elements),this.hidden=0,'string'==typeof this.options.placeholder){var a=this.options.placeholder;if(this.placeholderNode=document.createElement('div'),this.placeholderNode.id='holmes-placeholder',this._hideElement(this.placeholderNode),this.placeholderNode.innerHTML=a,this.elements[0].parentNode instanceof Element)this.elements[0].parentNode.appendChild(this.placeholderNode);else throw new Error(errors.impossiblePlaceholder)}if(this.options.class.visible){var b=this.options.class.visible;this.elementsArray.forEach(function(c){c.classList.add(b)})}this.input.addEventListener('input',this._inputHandler)}},{key:'stop',value:function(){var d=this;return new Promise(function(a,b){try{d.input.removeEventListener('input',d._inputHandler),d.options.placeholder&&(d.placeholderNode.parentNode?d.placeholderNode.parentNode.removeChild(d.placeholderNode):b(new Error(errors.impossiblePlaceholder))),d.options.mark&&d.elementsArray.forEach(function(b){b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,'')}),d.running=!1,a('This instance of Holmes has been stopped.')}catch(c){b(c)}})}},{key:'clear',value:function(){var c=this;this.setInput(''),this.elementsArray.forEach(function(a){c._showElement(a)}),this.options.placeholder&&this._hideElement(this.placeholderNode),this.hidden=0}},{key:'count',value:function(){return{all:this.elementsLength,hidden:this.hidden,visible:this.elementsLength-this.hidden}}}]),f}(),holmes=toFactory(Holmes);export default holmes; diff --git a/js/holmes.js b/js/holmes.js index 5ee408c..bb0938a 100644 --- a/js/holmes.js +++ b/js/holmes.js @@ -1 +1 @@ -(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define(b):a.holmes=b()})(this,function(){'use strict';var f='undefined'==typeof window?global:window,e=function(c,a){return-1!==c.indexOf(a)},g='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&'function'==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?'symbol':typeof a},h=function(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')},b=function(){function a(a,b){for(var c,d=0;di.searchString.length||(i.options.dynamic&&(i.elements=document.querySelectorAll(i.options.find),i.elementsLength=i.elements.length,i.elementsArray=Array.prototype.slice.call(i.elements)),i.options.mark&&(i._regex=new RegExp('('+i.searchString+')(?![^<]*>)','gi')),i.elementsArray.forEach(function(a){e(a.textContent.toLowerCase(),i.searchString)?(i._showElement(a),c&&'function'==typeof i.options.onFound&&i.options.onFound(i.placeholderNode),d=!0):i._hideElement(a)}),'function'==typeof i.options.onInput&&i.options.onInput(i.searchString),d?i.options.placeholder&&i._hideElement(i.placeholderNode):(i.options.placeholder&&i._showElement(i.placeholderNode),!1==c&&(c=!0,'function'==typeof i.options.onEmpty&&i.options.onEmpty(i.placeholderNode))))}}return b(f,[{key:'_hideElement',value:function(b){this.options.class.visible&&b.classList.remove(this.options.class.visible),b.classList.contains(this.options.class.hidden)||(b.classList.add(this.options.class.hidden),this.hidden++,'function'==typeof this.options.onHidden&&this.options.onHidden(b)),this.options.hiddenAttr&&b.setAttribute('hidden','true'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''))}},{key:'_showElement',value:function(b){this.options.class.visible&&b.classList.add(this.options.class.visible),b.classList.contains(this.options.class.hidden)&&(b.classList.remove(this.options.class.hidden),this.hidden--,'function'==typeof this.options.onVisible&&this.options.onVisible(b)),this.options.hiddenAttr&&b.removeAttribute('hidden'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''),this.searchString.length&&(b.innerHTML=b.innerHTML.replace(this._regex,'$1')))}},{key:'inputString',value:function(){if(this.input instanceof HTMLInputElement)return this.input.value.toLowerCase();if(this.input.contentEditable)return this.input.textContent.toLowerCase();throw new Error('The Holmes input was no or contenteditable.')}},{key:'setInput',value:function(b){if(this.input instanceof HTMLInputElement)this.input.value=b;else if(this.input.contentEditable)this.input.textContent=b;else throw new Error('The Holmes input was no or contenteditable.')}},{key:'start',value:function(){var d=document.querySelector(this.options.input);if(d instanceof HTMLElement)this.input=d;else throw new Error('Your Holmes.input didn\'t match a querySelector');if('string'==typeof this.options.find)this.elements=document.querySelectorAll(this.options.find);else throw new Error('A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like:\n\nnew Holmes({\n find:".result"\n});\n\nsee also https://haroen.me/holmes/doc/holmes.html');if(this.elementsLength=this.elements.length,this.elementsArray=Array.prototype.slice.call(this.elements),this.hidden=0,'string'==typeof this.options.placeholder){var a=this.options.placeholder;if(this.placeholderNode=document.createElement('div'),this.placeholderNode.id='holmes-placeholder',this._hideElement(this.placeholderNode),this.placeholderNode.innerHTML=a,this.elements[0].parentNode instanceof Element)this.elements[0].parentNode.appendChild(this.placeholderNode);else throw new Error('The Holmes placeholder couldn\'t be put; the elements had no parent.')}if(this.options.class.visible){var b=this.options.class.visible;this.elementsArray.forEach(function(c){c.classList.add(b)})}this.input.addEventListener('input',this._inputHandler)}},{key:'stop',value:function(){var d=this;return new Promise(function(a,b){try{d.input.removeEventListener('input',d._inputHandler),d.options.placeholder&&(d.placeholderNode.parentNode?d.placeholderNode.parentNode.removeChild(d.placeholderNode):b(new Error('The Holmes placeholderNode has no parent.'))),d.options.mark&&d.elementsArray.forEach(function(b){b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,'')}),d.running=!1,a('This instance of Holmes has been stopped.')}catch(c){b(c)}})}},{key:'clear',value:function(){var c=this;this.setInput(''),this.elementsArray.forEach(function(a){c._showElement(a)}),this.options.placeholder&&this._hideElement(this.placeholderNode),this.hidden=0}},{key:'count',value:function(){return{all:this.elementsLength,hidden:this.hidden,visible:this.elementsLength-this.hidden}}}]),f}(),c=function(g){var a=function(){for(var a,b=arguments.length,c=Array(b),d=0;d or contenteditable.',optionsObject:'The options need to be given inside an object like this:\n\nnew Holmes({\n find:".result"\n});\n\nsee also https://haroen.me/holmes/doc/holmes.html',findOption:'A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like:\n\nnew Holmes({\n find:".result"\n});\n\nsee also https://haroen.me/holmes/doc/holmes.html',noInput:'Your Holmes.input didn\'t match a querySelector',impossiblePlaceholder:'The Holmes placeholder couldn\'t be put; the elements had no parent.'},a=function(){function f(a){var j=this;h(this,f);var c=!1;if('object'!==('undefined'==typeof a?'undefined':g(a)))throw new Error(i.optionsObject);if('string'!=typeof a.find)throw new Error(i.findOption);var d={input:'input[type=search]',find:'',placeholder:void 0,mark:!1,class:{visible:void 0,hidden:'hidden'},dynamic:!1,minCharacters:0,hiddenAttr:!1,onHidden:void 0,onVisible:void 0,onEmpty:void 0,onFound:void 0,onInput:void 0};this.options=Object.assign({},d,a),this.options.class=Object.assign({},d.class,a.class),this.hidden=0,this.running=!1,window.addEventListener('DOMContentLoaded',function(){return j.start()}),this._inputHandler=function(){j.running=!0;var d=!1;j.searchString=j.inputString(),j.options.minCharacters&&0!==j.searchString.length&&j.options.minCharacters>j.searchString.length||(j.options.dynamic&&(j.elements=document.querySelectorAll(j.options.find),j.elementsLength=j.elements.length,j.elementsArray=Array.prototype.slice.call(j.elements)),j.options.mark&&(j._regex=new RegExp('('+j.searchString+')(?![^<]*>)','gi')),j.elementsArray.forEach(function(a){e(a.textContent.toLowerCase(),j.searchString)?(j._showElement(a),c&&'function'==typeof j.options.onFound&&j.options.onFound(j.placeholderNode),d=!0):j._hideElement(a)}),'function'==typeof j.options.onInput&&j.options.onInput(j.searchString),d?j.options.placeholder&&j._hideElement(j.placeholderNode):(j.options.placeholder&&j._showElement(j.placeholderNode),!1==c&&(c=!0,'function'==typeof j.options.onEmpty&&j.options.onEmpty(j.placeholderNode))))}}return b(f,[{key:'_hideElement',value:function(b){this.options.class.visible&&b.classList.remove(this.options.class.visible),b.classList.contains(this.options.class.hidden)||(b.classList.add(this.options.class.hidden),this.hidden++,'function'==typeof this.options.onHidden&&this.options.onHidden(b)),this.options.hiddenAttr&&b.setAttribute('hidden','true'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''))}},{key:'_showElement',value:function(b){this.options.class.visible&&b.classList.add(this.options.class.visible),b.classList.contains(this.options.class.hidden)&&(b.classList.remove(this.options.class.hidden),this.hidden--,'function'==typeof this.options.onVisible&&this.options.onVisible(b)),this.options.hiddenAttr&&b.removeAttribute('hidden'),this.options.mark&&(b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,''),this.searchString.length&&(b.innerHTML=b.innerHTML.replace(this._regex,'$1')))}},{key:'inputString',value:function(){if(this.input instanceof HTMLInputElement)return this.input.value.toLowerCase();if(this.input.contentEditable)return this.input.textContent.toLowerCase();throw new Error(i.invalidInput)}},{key:'setInput',value:function(b){if(this.input instanceof HTMLInputElement)this.input.value=b;else if(this.input.contentEditable)this.input.textContent=b;else throw new Error(i.invalidInput)}},{key:'start',value:function(){var d=document.querySelector(this.options.input);if(d instanceof HTMLElement)this.input=d;else throw new Error(i.noInput);if('string'==typeof this.options.find)this.elements=document.querySelectorAll(this.options.find);else throw new Error(i.findOption);if(this.elementsLength=this.elements.length,this.elementsArray=Array.prototype.slice.call(this.elements),this.hidden=0,'string'==typeof this.options.placeholder){var a=this.options.placeholder;if(this.placeholderNode=document.createElement('div'),this.placeholderNode.id='holmes-placeholder',this._hideElement(this.placeholderNode),this.placeholderNode.innerHTML=a,this.elements[0].parentNode instanceof Element)this.elements[0].parentNode.appendChild(this.placeholderNode);else throw new Error(i.impossiblePlaceholder)}if(this.options.class.visible){var b=this.options.class.visible;this.elementsArray.forEach(function(c){c.classList.add(b)})}this.input.addEventListener('input',this._inputHandler)}},{key:'stop',value:function(){var d=this;return new Promise(function(a,b){try{d.input.removeEventListener('input',d._inputHandler),d.options.placeholder&&(d.placeholderNode.parentNode?d.placeholderNode.parentNode.removeChild(d.placeholderNode):b(new Error(i.impossiblePlaceholder))),d.options.mark&&d.elementsArray.forEach(function(b){b.innerHTML=b.innerHTML.replace(/<\/?mark>/g,'')}),d.running=!1,a('This instance of Holmes has been stopped.')}catch(c){b(c)}})}},{key:'clear',value:function(){var c=this;this.setInput(''),this.elementsArray.forEach(function(a){c._showElement(a)}),this.options.placeholder&&this._hideElement(this.placeholderNode),this.hidden=0}},{key:'count',value:function(){return{all:this.elementsLength,hidden:this.hidden,visible:this.elementsLength-this.hidden}}}]),f}(),c=function(g){var a=function(){for(var a,b=arguments.length,c=Array(b),d=0;d or contenteditable.', + optionsObject: `The options need to be given inside an object like this: + +new Holmes({ + find:".result" +}); + +see also https://haroen.me/holmes/doc/holmes.html`, + findOption: `A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like: + +new Holmes({ + find:".result" +}); + +see also https://haroen.me/holmes/doc/holmes.html`, + noInput: `Your Holmes.input didn't match a querySelector`, + impossiblePlaceholder: `The Holmes placeholder couldn't be put; the elements had no parent.` +}; + /** * Callback used for changes in item en list states. * @callback onChange @@ -12,12 +32,14 @@ import type {OptionsType} from './types.js'; * onFound. * @memberOf holmes */ + /** * Callback used for changes in input value * @callback onInput * @param {string} input The value that is currently in the search field * @memberOf holmes */ + /** * @alias holmes */ @@ -91,28 +113,12 @@ class Holmes { let empty: boolean = false; if (typeof options !== 'object') { - throw new Error( - `The options need to be given inside an object like this: - -new Holmes({ - find:".result" -}); - -see also https://haroen.me/holmes/doc/holmes.html` - ); + throw new Error(errors.optionsObject); } // If this.options.find is missing, the searching won't work so we'll thrown an exceptions if (typeof options.find !== 'string') { - throw new Error( - `A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like: - -new Holmes({ - find:".result" -}); - -see also https://haroen.me/holmes/doc/holmes.html` - ); + throw new Error(errors.findOption); } const defaults = { @@ -353,7 +359,7 @@ see also https://haroen.me/holmes/doc/holmes.html` if (this.input.contentEditable) { return this.input.textContent.toLowerCase(); } - throw new Error('The Holmes input was no or contenteditable.'); + throw new Error(errors.invalidInput); } /** @@ -369,7 +375,7 @@ see also https://haroen.me/holmes/doc/holmes.html` } else if (this.input.contentEditable) { this.input.textContent = value; } else { - throw new Error('The Holmes input was no or contenteditable.'); + throw new Error(errors.invalidInput); } } @@ -386,21 +392,13 @@ see also https://haroen.me/holmes/doc/holmes.html` if (_input instanceof HTMLElement) { this.input = _input; } else { - throw new Error(`Your Holmes.input didn't match a querySelector`); + throw new Error(errors.noInput); } if (typeof this.options.find === 'string') { this.elements = document.querySelectorAll(this.options.find); } else { - throw new Error( - `A find argument is needed. That should be a querySelectorAll for each of the items you want to match individually. You should have something like: - -new Holmes({ - find:".result" -}); - -see also https://haroen.me/holmes/doc/holmes.html` - ); + throw new Error(errors.findOption); } /** @@ -430,9 +428,7 @@ see also https://haroen.me/holmes/doc/holmes.html` if (this.elements[0].parentNode instanceof Element) { this.elements[0].parentNode.appendChild(this.placeholderNode); } else { - throw new Error( - `The Holmes placeholder couldn't be put; the elements had no parent.` - ); + throw new Error(errors.impossiblePlaceholder); } } @@ -466,7 +462,7 @@ see also https://haroen.me/holmes/doc/holmes.html` if (this.placeholderNode.parentNode) { this.placeholderNode.parentNode.removeChild(this.placeholderNode); } else { - reject(new Error('The Holmes placeholderNode has no parent.')); + reject(new Error(errors.impossiblePlaceholder)); } }