1/** 2 * findAndReplaceDOMText v 0.4.6 3 * @author James Padolsey http://james.padolsey.com 4 * @license http://unlicense.org/UNLICENSE 5 * 6 * Matches the text of a DOM node against a regular expression 7 * and replaces each match (or node-separated portions of the match) 8 * in the specified element. 9 */(function(root,factory2){typeof module=="object"&&module.exports?module.exports=factory2():typeof define=="function"&&define.amd?define(factory2):root.findAndReplaceDOMText=factory2()})(this,function(){var PORTION_MODE_RETAIN="retain",PORTION_MODE_FIRST="first",doc=document,hasOwn={}.hasOwnProperty;function escapeRegExp(s){return String(s).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function exposed(){return deprecated.apply(null,arguments)||findAndReplaceDOMText.apply(null,arguments)}function deprecated(regex,node,replacement,captureGroup,elFilter){if(node&&!node.nodeType&&arguments.length<=2)return!1;var isReplacementFunction=typeof replacement=="function";isReplacementFunction&&(replacement=(function(original){return function(portion,match){return original(portion.text,match.startIndex)}})(replacement));var instance=findAndReplaceDOMText(node,{find:regex,wrap:isReplacementFunction?null:replacement,replace:isReplacementFunction?replacement:"$"+(captureGroup||"&"),prepMatch:function(m,mi){if(!m[0])throw"findAndReplaceDOMText cannot handle zero-length matches";if(captureGroup>0){var cg=m[captureGroup];m.index+=m[0].indexOf(cg),m[0]=cg}return m.endIndex=m.index+m[0].length,m.startIndex=m.index,m.index=mi,m},filterElements:elFilter});return exposed.revert=function(){return instance.revert()},!0}function findAndReplaceDOMText(node,options){return new Finder(node,options)}exposed.NON_PROSE_ELEMENTS={br:1,hr:1,script:1,style:1,img:1,video:1,audio:1,canvas:1,svg:1,map:1,object:1,input:1,textarea:1,select:1,option:1,optgroup:1,button:1},exposed.NON_CONTIGUOUS_PROSE_ELEMENTS={address:1,article:1,aside:1,blockquote:1,dd:1,div:1,dl:1,fieldset:1,figcaption:1,figure:1,footer:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,header:1,hgroup:1,hr:1,main:1,nav:1,noscript:1,ol:1,output:1,p:1,pre:1,section:1,ul:1,br:1,li:1,summary:1,dt:1,details:1,rp:1,rt:1,rtc:1,script:1,style:1,img:1,video:1,audio:1,canvas:1,svg:1,map:1,object:1,input:1,textarea:1,select:1,option:1,optgroup:1,button:1,table:1,tbody:1,thead:1,th:1,tr:1,td:1,caption:1,col:1,tfoot:1,colgroup:1},exposed.NON_INLINE_PROSE=function(el){return hasOwn.call(exposed.NON_CONTIGUOUS_PROSE_ELEMENTS,el.nodeName.toLowerCase())},exposed.PRESETS={prose:{forceContext:exposed.NON_INLINE_PROSE,filterElements:function(el){return!hasOwn.call(exposed.NON_PROSE_ELEMENTS,el.nodeName.toLowerCase())}}},exposed.Finder=Finder;function Finder(node,options){var preset=options.preset&&exposed.PRESETS[options.preset];if(options.portionMode=options.portionMode||PORTION_MODE_RETAIN,preset)for(var i in preset)hasOwn.call(preset,i)&&!hasOwn.call(options,i)&&(options[i]=preset[i]);this.node=node,this.options=options,this.prepMatch=options.prepMatch||this.prepMatch,this.reverts=[],this.matches=this.search(),this.matches.length&&this.processMatches()}return Finder.prototype={search:function(){var match,matchIndex=0,offset=0,regex=this.options.find,textAggregation=this.getAggregateText(),matches=[],self=this;regex=typeof regex=="string"?RegExp(escapeRegExp(regex),"g"):regex,matchAggregation(textAggregation);function matchAggregation(textAggregation2){for(var i=0,l=textAggregation2.length;i<l;++i){var text=textAggregation2[i];if(typeof text!="string"){matchAggregation(text);continue}if(regex.global)for(;match=regex.exec(text);)matches.push(self.prepMatch(match,matchIndex++,offset));else(match=text.match(regex))&&matches.push(self.prepMatch(match,0,offset));offset+=text.length}}return matches},prepMatch:function(match,matchIndex,characterOffset){if(!match[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");return match.endIndex=characterOffset+match.index+match[0].length,match.startIndex=characterOffset+match.index,match.index=matchIndex,match},getAggregateText:function(){var elementFilter=this.options.filterElements,forceContext=this.options.forceContext;return getText(this.node);function getText(node){if(node.nodeType===Node.TEXT_NODE)return[node.data];if(elementFilter&&!elementFilter(node))return[];var txt=[""],i=0;if(node=node.firstChild)do{if(node.nodeType===Node.TEXT_NODE){txt[i]+=node.data;continue}var innerText=getText(node);forceContext&&node.nodeType===Node.ELEMENT_NODE&&(forceContext===!0||forceContext(node))?(txt[++i]=innerText,txt[++i]=""):(typeof innerText[0]=="string"&&(txt[i]+=innerText.shift()),innerText.length&&(txt[++i]=innerText,txt[++i]=""))}while(node=node.nextSibling);return txt}},processMatches:function(){var matches=this.matches,node=this.node,elementFilter=this.options.filterElements,startPortion,endPortion,innerPortions=[],curNode=node,match=matches.shift(),atIndex=0,matchIndex=0,portionIndex=0,doAvoidNode,nodeStack=[node];out:for(;;){if(curNode.nodeType===Node.TEXT_NODE&&(!endPortion&&curNode.length+atIndex>=match.endIndex?endPortion={node:curNode,index:portionIndex++,text:curNode.data.substring(match.startIndex-atIndex,match.endIndex-atIndex),indexInMatch:atIndex===0?0:atIndex-match.startIndex,indexInNode:match.startIndex-atIndex,endIndexInNode:match.endIndex-atIndex,isEnd:!0}:startPortion&&innerPortions.push({node:curNode,index:portionIndex++,text:curNode.data,indexInMatch:atIndex-match.startIndex,indexInNode:0}),!startPortion&&curNode.length+atIndex>match.startIndex&&(startPortion={node:curNode,index:portionIndex++,indexInMatch:0,indexInNode:match.startIndex-atIndex,endIndexInNode:match.endIndex-atIndex,text:curNode.data.substring(match.startIndex-atIndex,match.endIndex-atIndex)}),atIndex+=curNode.data.length),doAvoidNode=curNode.nodeType===Node.ELEMENT_NODE&&elementFilter&&!elementFilter(curNode),startPortion&&endPortion){if(curNode=this.replaceMatch(match,startPortion,innerPortions,endPortion),atIndex-=endPortion.node.data.length-endPortion.endIndexInNode,startPortion=null,endPortion=null,innerPortions=[],match=matches.shift(),portionIndex=0,matchIndex++,!match)break}else if(!doAvoidNode&&(curNode.firstChild||curNode.nextSibling)){curNode.firstChild?(nodeStack.push(curNode),curNode=curNode.firstChild):curNode=curNode.nextSibling;continue}for(;;){if(curNode.nextSibling){curNode=curNode.nextSibling;break}if(curNode=nodeStack.pop(),curNode===node)break out}}},revert:function(){for(var l=this.reverts.length;l--;)this.reverts[l]();this.reverts=[]},prepareReplacementString:function(string,portion,match){var portionMode=this.options.portionMode;return portionMode===PORTION_MODE_FIRST&&portion.indexInMatch>
90?"":(string=string.replace(/\$(\d+|&|`|')/g,function($0,t){var replacement;switch(t){case"&":replacement=match[0];break;case"`":replacement=match.input.substring(0,match.startIndex);break;case"'":replacement=match.input.substring(match.endIndex);break;default:replacement=match[+t]||""}return replacement}),portionMode===PORTION_MODE_FIRST?string:portion.isEnd?string.substring(portion.indexInMatch):string.substring(portion.indexInMatch,portion.indexInMatch+portion.text.length))},getPortionReplacementNode:function(portion,match){var replacement=this.options.replace||"$&",wrapper=this.options.wrap,wrapperClass=this.options.wrapClass;if(wrapper&&wrapper.nodeType){var clone=doc.createElement("div");clone.innerHTML=wrapper.outerHTML||new XMLSerializer().serializeToString(wrapper),wrapper=clone.firstChild}if(typeof replacement=="function")return replacement=replacement(portion,match),replacement&&replacement.nodeType?replacement:doc.createTextNode(String(replacement));var el=typeof wrapper=="string"?doc.createElement(wrapper):wrapper;return el&&wrapperClass&&(el.className=wrapperClass),replacement=doc.createTextNode(this.prepareReplacementString(replacement,portion,match)),!replacement.data||!el?replacement:(el.appendChild(replacement),el)},replaceMatch:function(match,startPortion,innerPortions,endPortion){var matchStartNode=startPortion.node,matchEndNode=endPortion.node,precedingTextNode,followingTextNode;if(matchStartNode===matchEndNode){var node=matchStartNode;startPortion.indexInNode>0&&(precedingTextNode=doc.createTextNode(node.data.substring(0,startPortion.indexInNode)),node.parentNode.insertBefore(precedingTextNode,node));var newNode=this.getPortionReplacementNode(endPortion,match);return node.parentNode.insertBefore(newNode,node),endPortion.endIndexInNode<node.length&&(followingTextNode=doc.createTextNode(node.data.substring(endPortion.endIndexInNode)),node.parentNode.insertBefore(followingTextNode,node)),node.parentNode.removeChild(node),this.reverts.push(function(){precedingTextNode===newNode.previousSibling&&precedingTextNode.parentNode.removeChild(precedingTextNode),followingTextNode===newNode.nextSibling&&followingTextNode.parentNode.removeChild(followingTextNode),newNode.parentNode.replaceChild(node,newNode)}),newNode}else{precedingTextNode=doc.createTextNode(matchStartNode.data.substring(0,startPortion.indexInNode)),followingTextNode=doc.createTextNode(matchEndNode.data.substring(endPortion.endIndexInNode));for(var firstNode=this.getPortionReplacementNode(startPortion,match),innerNodes=[],i=0,l=innerPortions.length;i<l;++i){var portion=innerPortions[i],innerNode=this.getPortionReplacementNode(portion,match);portion.node.parentNode.replaceChild(innerNode,portion.node),this.reverts.push((function(portion2,innerNode2){return function(){innerNode2.parentNode.replaceChild(portion2.node,innerNode2)}})(portion,innerNode)),innerNodes.push(innerNode)}var lastNode=this.getPortionReplacementNode(endPortion,match);return matchStartNode.parentNode.insertBefore(precedingTextNode,matchStartNode),matchStartNode.parentNode.insertBefore(firstNode,matchStartNode),matchStartNode.parentNode.removeChild(matchStartNode),matchEndNode.parentNode.insertBefore(lastNode,matchEndNode),matchEndNode.parentNode.insertBefore(followingTextNode,matchEndNode),matchEndNode.parentNode.removeChild(matchEndNode),this.reverts.push(function(){precedingTextNode.parentNode.removeChild(precedingTextNode),firstNode.parentNode.replaceChild(matchStartNode,firstNode),followingTextNode.parentNode.removeChild(followingTextNode),lastNode.parentNode.replaceChild(matchEndNode,lastNode)}),lastNode}}},exposed}); 10//# sourceMappingURL=/cdn/shop/t/67/assets/recipe.js.map?v=53759884358016971561787071176
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.