Files
moodle/lib/amd/build/mustache.min.js
Andrew Nicols e1b9d5f3cd MDL-73915 js: Drop support for IE and android
Moodle announced that support for IE would be dropped back in August
2020 with Moodle 3.9 but not active steps were taken at that time. That
decision was made in MDLSITE-6109 and this particular step was meant to
be taken in Moodle 3.10.

This is the first step taken to actively drop support for IE.

This commit also bumps the browser support pattern from 0.25% to 0.3%.
The percentage here includes any browser where at least this percentage
of users worldwide may be using a browser. In this case it causes
support for Android 4.3-4.4 to be dropped, which relate to Android
KitKat (released 2013).

This combination of changes means that all of the supported browsers in
our compatibility list support modern features including async,
for...of, classes, native Promises, and more which has a huge impact on
the ease of debugging code, and drastically reduces the minified file
size because a number of native Polyfills included by Babel are no
longer included.
2022-02-23 08:55:20 +08:00

3 lines
11 KiB
JavaScript

var global,factory;global=window,factory=function(mustache){var objectToString=Object.prototype.toString,isArray=Array.isArray||function(object){return"[object Array]"===objectToString.call(object)};function isFunction(object){return"function"==typeof object}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return null!=obj&&"object"==typeof obj&&propName in obj}var regExpTest=RegExp.prototype.test,nonSpaceRe=/\S/;function isWhitespace(string){return!function(re,string){return regExpTest.call(re,string)}(nonSpaceRe,string)}var entityMap={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},whiteRe=/\s*/,spaceRe=/\s+/,equalsRe=/\s*=/,curlyRe=/\s*\}/,tagRe=/#|\^|\/|>|\{|&|=|!|\$|</;function Scanner(string){this.string=string,this.tail=string,this.pos=0}function Context(view,parentContext){this.view=view,this.blocks={},this.cache={".":this.view},this.parent=parentContext}function Writer(){this.cache={}}Scanner.prototype.eos=function(){return""===this.tail},Scanner.prototype.scan=function(re){var match=this.tail.match(re);if(!match||0!==match.index)return"";var string=match[0];return this.tail=this.tail.substring(string.length),this.pos+=string.length,string},Scanner.prototype.scanUntil=function(re){var match,index=this.tail.search(re);switch(index){case-1:match=this.tail,this.tail="";break;case 0:match="";break;default:match=this.tail.substring(0,index),this.tail=this.tail.substring(index)}return this.pos+=match.length,match},Context.prototype.push=function(view){return new Context(view,this)},Context.prototype.setBlockVar=function(name,value){return this.blocks[name]=value,value},Context.prototype.clearBlockVars=function(){this.blocks={}},Context.prototype.getBlockVar=function(name){var value,blocks=this.blocks;return blocks.hasOwnProperty(name)?value=blocks[name]:this.parent&&(value=this.parent.getBlockVar(name)),value},Context.prototype.lookup=function(name){var value,primitive,propName,cache=this.cache;if(cache.hasOwnProperty(name))value=cache[name];else{for(var intermediateValue,names,index,context=this,lookupHit=!1;context;){if(name.indexOf(".")>0)for(intermediateValue=context.view,names=name.split("."),index=0;null!=intermediateValue&&index<names.length;)index===names.length-1&&(lookupHit=hasProperty(intermediateValue,names[index])||(primitive=intermediateValue,propName=names[index],null!=primitive&&"object"!=typeof primitive&&primitive.hasOwnProperty&&primitive.hasOwnProperty(propName))),intermediateValue=intermediateValue[names[index++]];else intermediateValue=context.view[name],lookupHit=hasProperty(context.view,name);if(lookupHit){value=intermediateValue;break}context=context.parent}cache[name]=value}return isFunction(value)&&(value=value.call(this.view)),value},Writer.prototype.clearCache=function(){this.cache={}},Writer.prototype.parse=function(template,tags){var cache=this.cache,cacheKey=template+":"+(tags||mustache.tags).join(":"),tokens=cache[cacheKey];return null==tokens&&(tokens=cache[cacheKey]=function(template,tags){if(!template)return[];var openingTagRe,closingTagRe,closingCurlyRe,lineHasNonSpace=!1,sections=[],tokens=[],spaces=[],hasTag=!1,nonSpace=!1,indentation="",tagIndex=0;function stripSpace(){if(hasTag&&!nonSpace)for(;spaces.length;)delete tokens[spaces.pop()];else spaces=[];hasTag=!1,nonSpace=!1}function compileTags(tagsToCompile){if("string"==typeof tagsToCompile&&(tagsToCompile=tagsToCompile.split(spaceRe,2)),!isArray(tagsToCompile)||2!==tagsToCompile.length)throw new Error("Invalid tags: "+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+"\\s*"),closingTagRe=new RegExp("\\s*"+escapeRegExp(tagsToCompile[1])),closingCurlyRe=new RegExp("\\s*"+escapeRegExp("}"+tagsToCompile[1]))}compileTags(tags||mustache.tags);for(var start,type,value,chr,token,openSection,scanner=new Scanner(template);!scanner.eos();){if(start=scanner.pos,value=scanner.scanUntil(openingTagRe))for(var i=0,valueLength=value.length;i<valueLength;++i)isWhitespace(chr=value.charAt(i))?(spaces.push(tokens.length),indentation+=chr):(nonSpace=!0,lineHasNonSpace=!0,indentation+=" "),tokens.push(["text",chr,start,start+1]),start+=1,"\n"===chr&&(stripSpace(),indentation="",tagIndex=0,lineHasNonSpace=!1);if(!scanner.scan(openingTagRe))break;if(hasTag=!0,type=scanner.scan(tagRe)||"name",scanner.scan(whiteRe),"="===type?(value=scanner.scanUntil(equalsRe),scanner.scan(equalsRe),scanner.scanUntil(closingTagRe)):"{"===type?(value=scanner.scanUntil(closingCurlyRe),scanner.scan(curlyRe),scanner.scanUntil(closingTagRe),type="&"):value=scanner.scanUntil(closingTagRe),!scanner.scan(closingTagRe))throw new Error("Unclosed tag at "+scanner.pos);if(token=">"==type?[type,value,start,scanner.pos,indentation,tagIndex,lineHasNonSpace]:[type,value,start,scanner.pos],tagIndex++,tokens.push(token),"#"===type||"^"===type||"$"===type||"<"===type)sections.push(token);else if("/"===type){if(!(openSection=sections.pop()))throw new Error('Unopened section "'+value+'" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section "'+openSection[1]+'" at '+start)}else"name"===type||"{"===type||"&"===type?nonSpace=!0:"="===type&&compileTags(value)}if(stripSpace(),openSection=sections.pop())throw new Error('Unclosed section "'+openSection[1]+'" at '+scanner.pos);return function(tokens){for(var token,nestedTokens=[],collector=nestedTokens,sections=[],i=0,numTokens=tokens.length;i<numTokens;++i)switch((token=tokens[i])[0]){case"$":case"<":case"#":case"^":collector.push(token),sections.push(token),collector=token[4]=[];break;case"/":sections.pop()[5]=token[2],collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}return nestedTokens}(function(tokens){for(var token,lastToken,squashedTokens=[],i=0,numTokens=tokens.length;i<numTokens;++i)(token=tokens[i])&&("text"===token[0]&&lastToken&&"text"===lastToken[0]?(lastToken[1]+=token[1],lastToken[3]=token[3]):(squashedTokens.push(token),lastToken=token));return squashedTokens}(tokens))}(template,tags)),tokens},Writer.prototype.render=function(template,view,partials,tags){var tokens=this.parse(template,tags),context=view instanceof Context?view:new Context(view);return this.renderTokens(tokens,context,partials,template,tags)},Writer.prototype.renderTokens=function(tokens,context,partials,originalTemplate,tags){for(var token,symbol,value,buffer="",i=0,numTokens=tokens.length;i<numTokens;++i)value=void 0,"#"===(symbol=(token=tokens[i])[0])?value=this.renderSection(token,context,partials,originalTemplate):"^"===symbol?value=this.renderInverted(token,context,partials,originalTemplate):">"===symbol?value=this.renderPartial(token,context,partials,tags):"<"===symbol?value=this.renderBlock(token,context,partials,originalTemplate):"$"===symbol?value=this.renderBlockVariable(token,context,partials,originalTemplate):"&"===symbol?value=this.unescapedValue(token,context):"name"===symbol?value=this.escapedValue(token,context):"text"===symbol&&(value=this.rawValue(token)),void 0!==value&&(buffer+=value);return buffer},Writer.prototype.renderSection=function(token,context,partials,originalTemplate){var self=this,buffer="",value=context.lookup(token[1]);if(value){if(isArray(value))for(var j=0,valueLength=value.length;j<valueLength;++j)buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate);else if("object"==typeof value||"string"==typeof value||"number"==typeof value)buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate);else if(isFunction(value)){if("string"!=typeof originalTemplate)throw new Error("Cannot use higher-order sections without the original template");null!=(value=value.call(context.view,originalTemplate.slice(token[3],token[5]),(function(template){return self.render(template,context,partials)})))&&(buffer+=value)}else buffer+=this.renderTokens(token[4],context,partials,originalTemplate);return buffer}},Writer.prototype.renderInverted=function(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&0===value.length)return this.renderTokens(token[4],context,partials,originalTemplate)},Writer.prototype.indentPartial=function(partial,indentation,lineHasNonSpace){for(var filteredIndentation=indentation.replace(/[^ \t]/g,""),partialByNl=partial.split("\n"),i=0;i<partialByNl.length;i++)partialByNl[i].length&&(i>0||!lineHasNonSpace)&&(partialByNl[i]=filteredIndentation+partialByNl[i]);return partialByNl.join("\n")},Writer.prototype.renderPartial=function(token,context,partials,tags){if(partials){var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(null!=value){var lineHasNonSpace=token[6],tagIndex=token[5],indentation=token[4],indentedValue=value;return 0==tagIndex&&indentation&&(indentedValue=this.indentPartial(value,indentation,lineHasNonSpace)),this.renderTokens(this.parse(indentedValue,tags),context,partials,indentedValue)}}},Writer.prototype.renderBlock=function(token,context,partials,originalTemplate){if(partials){var value=isFunction(partials)?partials(token[1]):partials[token[1]];null!=value&&context.clearBlockVars(),this.renderTokens(token[4],context,partials,originalTemplate);var result=this.renderTokens(this.parse(value),context,partials,value);return context.clearBlockVars(),result}},Writer.prototype.renderBlockVariable=function(token,context,partials,originalTemplate){var value=token[1],exists=context.getBlockVar(value);return exists?this.renderTokens(this.parse(exists),context,partials,exists):(context.setBlockVar(value,originalTemplate.slice(token[3],token[5])),this.renderTokens(token[4],context,partials,originalTemplate))},Writer.prototype.unescapedValue=function(token,context){var value=context.lookup(token[1]);if(null!=value)return value},Writer.prototype.escapedValue=function(token,context){var value=context.lookup(token[1]);if(null!=value)return mustache.escape(value)},Writer.prototype.rawValue=function(token){return token[1]},mustache.name="mustache.js",mustache.version="3.1.0",mustache.tags=["{{","}}"];var defaultWriter=new Writer;return mustache.clearCache=function(){return defaultWriter.clearCache()},mustache.parse=function(template,tags){return defaultWriter.parse(template,tags)},mustache.render=function(template,view,partials,tags){if("string"!=typeof template)throw new TypeError('Invalid template! Template should be a "string" but "'+(isArray(obj=template)?"array":typeof obj)+'" was given as the first argument for mustache#render(template, view, partials)');var obj;return defaultWriter.render(template,view,partials,tags)},mustache.to_html=function(template,view,partials,send){var result=mustache.render(template,view,partials);if(!isFunction(send))return result;send(result)},mustache.escape=function(string){return String(string).replace(/[&<>"'`=\/]/g,(function(s){return entityMap[s]}))},mustache.Scanner=Scanner,mustache.Context=Context,mustache.Writer=Writer,mustache},"object"==typeof exports&&exports&&"string"!=typeof exports.nodeName?factory(exports):"function"==typeof define&&define.amd?define("core/mustache",["exports"],factory):(global.Mustache={},factory(global.Mustache));
//# sourceMappingURL=mustache.min.js.map