vendor: 42,605 bytes, lines 1-1473
1 2 3/*! Picturefill - v3.0.2 4 * http://scottjehl.github.io/picturefill 5 * Copyright (c) 2015 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; 6 * License: MIT 7 */ 8 9(function( window, document, undefined ) { 10 // Enable strict mode 11 "use strict"; 12 13 // HTML shim|v it for old IE (IE9 will still need the HTML video tag workaround) 14 document.createElement( "picture" ); 15 16 var warn, eminpx, alwaysCheckWDescriptor, evalId; 17 // local object for method references and testing exposure 18 var pf = {}; 19 var isSupportTestReady = false; 20 var noop = function() {}; 21 var image = document.createElement( "img" ); 22 var getImgAttr = image.getAttribute; 23 var setImgAttr = image.setAttribute; 24 var removeImgAttr = image.removeAttribute; 25 var docElem = document.documentElement; 26 var types = {}; 27 var cfg = { 28 //resource selection: 29 algorithm: "" 30 }; 31 var srcAttr = "data-pfsrc"; 32 var srcsetAttr = srcAttr + "set"; 33 // ua sniffing is done for undetectable img loading features, 34 // to do some non crucial perf optimizations 35 var ua = navigator.userAgent; 36 var supportAbort = (/rident/).test(ua) || ((/ecko/).test(ua) && ua.match(/rv\:(\d+)/) && RegExp.$1 > 35 ); 37 var curSrcProp = "currentSrc"; 38 var regWDesc = /\s+\+?\d+(e\d+)?w/; 39 var regSize = /(\([^)]+\))?\s*(.+)/; 40 var setOptions = window.picturefillCFG; 41 /** 42 * Shortcut property for https://w3c.github.io/webappsec/specs/mixedcontent/#restricts-mixed-content ( for easy overriding in tests ) 43 */ 44 // baseStyle also used by getEmValue (i.e.: width: 1em is important) 45 var baseStyle = "position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)"; 46 var fsCss = "font-size:100%!important;"; 47 var isVwDirty = true; 48 49 var cssCache = {}; 50 var sizeLengthCache = {}; 51 var DPR = window.devicePixelRatio; 52 var units = { 53 px: 1, 54 "in": 96 55 }; 56 var anchor = document.createElement( "a" ); 57 /** 58 * alreadyRun flag used for setOptions. is it true setOptions will reevaluate 59 * @type {boolean} 60 */ 61 var alreadyRun = false; 62 63 // Reusable, non-"g" Regexes 64 65 // (Don't use \s, to avoid matching non-breaking space.) 66 var regexLeadingSpaces = /^[ \t\n\r\u000c]+/, 67 regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/, 68 regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/, 69 regexTrailingCommas = /[,]+$/, 70 regexNonNegativeInteger = /^\d+$/, 71 72 // ( Positive or negative or unsigned integers or decimals, without or without exponents. 73 // Must include at least one digit. 74 // According to spec tests any decimal point must be followed by a digit. 75 // No leading plus sign is allowed.) 76 // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number 77 regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/; 78 79 var on = function(obj, evt, fn, capture) { 80 if ( obj.addEventListener ) { 81 obj.addEventListener(evt, fn, capture || false); 82 } else if ( obj.attachEvent ) { 83 obj.attachEvent( "on" + evt, fn); 84 } 85 }; 86 87 /** 88 * simple memoize function: 89 */ 90 91 var memoize = function(fn) { 92 var cache = {}; 93 return function(input) { 94 if ( !(input in cache) ) { 95 cache[ input ] = fn(input); 96 } 97 return cache[ input ]; 98 }; 99 }; 100 101 // UTILITY FUNCTIONS 102 103 // Manual is faster than RegEx 104 // http://jsperf.com/whitespace-character/5 105 function isSpace(c) { 106 return (c === "\u0020" || // space 107 c === "\u0009" || // horizontal tab 108 c === "\u000A" || // new line 109 c === "\u000C" || // form feed 110 c === "\u000D"); // carriage return 111 } 112 113 /** 114 * gets a mediaquery and returns a boolean or gets a css length and returns a number 115 * @param css mediaqueries or css length 116 * @returns {boolean|number} 117 * 118 * based on: https://gist.github.com/jonathantneal/db4f77009b155f083738 119 */ 120 var evalCSS = (function() { 121 122 var regLength = /^([\d\.]+)(em|vw|px)$/; 123 var replace = function() { 124 var args = arguments, index = 0, string = args[0]; 125 while (++index in args) { 126 string = string.replace(args[index], args[++index]); 127 } 128 return string; 129 }; 130 131 var buildStr = memoize(function(css) { 132 133 return "return " + replace((css || "").toLowerCase(), 134 // interpret `and` 135 /\band\b/g, "&&", 136 137 // interpret `,` 138 /,/g, "||", 139 140 // interpret `min-` as >= 141 /min-([a-z-\s]+):/g, "e.$1>=", 142 143 // interpret `max-` as <= 144 /max-([a-z-\s]+):/g, "e.$1<=", 145 146 //calc value 147 /calc([^)]+)/g, "($1)", 148 149 // interpret css values 150 /(\d+[\.]*[\d]*)([a-z]+)/g, "($1 * e.$2)", 151 //make eval less evil 152 /^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/ig, "" 153 ) + ";"; 154 }); 155 156 return function(css, length) { 157 var parsedLength; 158 if (!(css in cssCache)) { 159 cssCache[css] = false; 160 if (length && (parsedLength = css.match( regLength ))) { 161 cssCache[css] = parsedLength[ 1 ] * units[parsedLength[ 2 ]]; 162 } else { 163 /*jshint evil:true */ 164 try{ 165 cssCache[css] = new Function("e", buildStr(css))(units); 166 } catch(e) {} 167 /*jshint evil:false */ 168 } 169 } 170 return cssCache[css]; 171 }; 172 })(); 173 174 var setResolution = function( candidate, sizesattr ) { 175 if ( candidate.w ) { // h = means height: || descriptor.type === 'h' do not handle yet... 176 candidate.cWidth = pf.calcListLength( sizesattr || "100vw" ); 177 candidate.res = candidate.w / candidate.cWidth ; 178 } else { 179 candidate.res = candidate.d; 180 } 181 return candidate; 182 }; 183 184 /** 185 * 186 * @param opt 187 */ 188 var picturefill = function( opt ) { 189 190 if (!isSupportTestReady) {return;} 191 192 var elements, i, plen; 193 194 var options = opt || {}; 195 196 if ( options.elements && options.elements.nodeType === 1 ) { 197 if ( options.elements.nodeName.toUpperCase() === "IMG" ) { 198 options.elements = [ options.elements ]; 199 } else { 200 options.context = options.elements; 201 options.elements = null; 202 } 203 } 204 205 elements = options.elements || pf.qsa( (options.context || document), ( options.reevaluate || options.reselect ) ? pf.sel : pf.selShort ); 206 207 if ( (plen = elements.length) ) { 208 209 pf.setupRun( options ); 210 alreadyRun = true; 211 212 // Loop through all elements 213 for ( i = 0; i < plen; i++ ) { 214 pf.fillImg(elements[ i ], options); 215 } 216 217 pf.teardownRun( options ); 218 } 219 }; 220 221 /** 222 * outputs a warning for the developer 223 * @param {message} 224 * @type {Function} 225 */ 226 warn = ( window.console && console.warn ) ? 227 function( message ) { 228 console.warn( message ); 229 } : 230 noop 231 ; 232 233 if ( !(curSrcProp in image) ) { 234 curSrcProp = "src"; 235 } 236 237 // Add support for standard mime types. 238 types[ "image/jpeg" ] = true; 239 types[ "image/gif" ] = true; 240 types[ "image/png" ] = true; 241 242 function detectTypeSupport( type, typeUri ) { 243 // based on Modernizr's lossless img-webp test 244 // note: asynchronous 245 var image = new window.Image(); 246 image.onerror = function() { 247 types[ type ] = false; 248 picturefill(); 249 }; 250 image.onload = function() { 251 types[ type ] = image.width === 1; 252 picturefill(); 253 }; 254 image.src = typeUri; 255 return "pending"; 256 } 257 258 // test svg support 259 types[ "image/svg+xml" ] = document.implementation.hasFeature( "http://www.w3.org/TR/SVG11/feature#Image", "1.1" ); 260 261 /** 262 * updates the internal vW property with the current viewport width in px 263 */ 264 function updateMetrics() { 265 266 isVwDirty = false; 267 DPR = window.devicePixelRatio; 268 cssCache = {}; 269 sizeLengthCache = {}; 270 271 pf.DPR = DPR || 1; 272 273 units.width = Math.max(window.innerWidth || 0, docElem.clientWidth); 274 units.height = Math.max(window.innerHeight || 0, docElem.clientHeight); 275 276 units.vw = units.width / 100; 277 units.vh = units.height / 100; 278 279 evalId = [ units.height, units.width, DPR ].join("-"); 280 281 units.em = pf.getEmValue(); 282 units.rem = units.em; 283 } 284 285 function chooseLowRes( lowerValue, higherValue, dprValue, isCached ) { 286 var bonusFactor, tooMuch, bonus, meanDensity; 287 288 //experimental 289 if (cfg.algorithm === "saveData" ){ 290 if ( lowerValue > 2.7 ) { 291 meanDensity = dprValue + 1; 292 } else { 293 tooMuch = higherValue - dprValue; 294 bonusFactor = Math.pow(lowerValue - 0.6, 1.5); 295 296 bonus = tooMuch * bonusFactor; 297 298 if (isCached) { 299 bonus += 0.1 * bonusFactor; 300 } 301 302 meanDensity = lowerValue + bonus; 303 } 304 } else { 305 meanDensity = (dprValue > 1) ? 306 Math.sqrt(lowerValue * higherValue) : 307 lowerValue; 308 } 309 310 return meanDensity > dprValue; 311 } 312 313 function applyBestCandidate( img ) { 314 var srcSetCandidates; 315 var matchingSet = pf.getSet( img ); 316 var evaluated = false; 317 if ( matchingSet !== "pending" ) { 318 evaluated = evalId; 319 if ( matchingSet ) { 320 srcSetCandidates = pf.setRes( matchingSet ); 321 pf.applySetCandidate( srcSetCandidates, img ); 322 } 323 } 324 img[ pf.ns ].evaled = evaluated; 325 } 326 327 function ascendingSort( a, b ) { 328 return a.res - b.res; 329 } 330 331 function setSrcToCur( img, src, set ) { 332 var candidate; 333 if ( !set && src ) { 334 set = img[ pf.ns ].sets; 335 set = set && set[set.length - 1]; 336 } 337 338 candidate = getCandidateForSrc(src, set); 339 340 if ( candidate ) { 341 src = pf.makeUrl(src); 342 img[ pf.ns ].curSrc = src; 343 img[ pf.ns ].curCan = candidate; 344 345 if ( !candidate.res ) { 346 setResolution( candidate, candidate.set.sizes ); 347 } 348 } 349 return candidate; 350 } 351 352 function getCandidateForSrc( src, set ) { 353 var i, candidate, candidates; 354 if ( src && set ) { 355 candidates = pf.parseSet( set ); 356 src = pf.makeUrl(src); 357 for ( i = 0; i < candidates.length; i++ ) { 358 if ( src === pf.makeUrl(candidates[ i ].url) ) { 359 candidate = candidates[ i ]; 360 break; 361 } 362 } 363 } 364 return candidate; 365 } 366 367 function getAllSourceElements( picture, candidates ) { 368 var i, len, source, srcset; 369 370 // SPEC mismatch intended for size and perf: 371 // actually only source elements preceding the img should be used 372 // also note: don't use qsa here, because IE8 sometimes doesn't like source as the key part in a selector 373 var sources = picture.getElementsByTagName( "source" ); 374 375 for ( i = 0, len = sources.length; i < len; i++ ) { 376 source = sources[ i ]; 377 source[ pf.ns ] = true; 378 srcset = source.getAttribute( "srcset" ); 379 380 // if source does not have a srcset attribute, skip 381 if ( srcset ) { 382 candidates.push( { 383 srcset: srcset, 384 media: source.getAttribute( "media" ), 385 type: source.getAttribute( "type" ), 386 sizes: source.getAttribute( "sizes" ) 387 } ); 388 } 389 } 390 } 391 392 /** 393 * Srcset Parser 394 * By Alex Bell | MIT License 395 * 396 * @returns Array [{url: _, d: _, w: _, h:_, set:_(????)}, ...] 397 * 398 * Based super duper closely on the reference algorithm at: 399 * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-srcset-attribute 400 */ 401 402 // 1. Let input be the value passed to this algorithm. 403 // (TO-DO : Explain what "set" argument is here. Maybe choose a more 404 // descriptive & more searchable name. Since passing the "set" in really has 405 // nothing to do with parsing proper, I would prefer this assignment eventually 406 // go in an external fn.) 407 function parseSrcset(input, set) { 408 409 function collectCharacters(regEx) { 410 var chars, 411 match = regEx.exec(input.substring(pos)); 412 if (match) { 413 chars = match[ 0 ]; 414 pos += chars.length; 415 return chars; 416 } 417 } 418 419 var inputLength = input.length, 420 url, 421 descriptors, 422 currentDescriptor, 423 state, 424 c, 425 426 // 2. Let position be a pointer into input, initially pointing at the start 427 // of the string. 428 pos = 0, 429 430 // 3. Let candidates be an initially empty source set. 431 candidates = []; 432 433 /** 434 * Adds descriptor properties to a candidate, pushes to the candidates array 435 * @return undefined 436 */ 437 // (Declared outside of the while loop so that it's only created once. 438 // (This fn is defined before it is used, in order to pass JSHINT. 439 // Unfortunately this breaks the sequencing of the spec comments. :/ ) 440 function parseDescriptors() { 441 442 // 9. Descriptor parser: Let error be no. 443 var pError = false, 444 445 // 10. Let width be absent. 446 // 11. Let density be absent. 447 // 12. Let future-compat-h be absent. (We're implementing it now as h) 448 w, d, h, i, 449 candidate = {}, 450 desc, lastChar, value, intVal, floatVal; 451 452 // 13. For each descriptor in descriptors, run the appropriate set of steps 453 // from the following list: 454 for (i = 0 ; i < descriptors.length; i++) { 455 desc = descriptors[ i ]; 456 457 lastChar = desc[ desc.length - 1 ]; 458 value = desc.substring(0, desc.length - 1); 459 intVal = parseInt(value, 10); 460 floatVal = parseFloat(value); 461 462 // If the descriptor consists of a valid non-negative integer followed by 463 // a U+0077 LATIN SMALL LETTER W character 464 if (regexNonNegativeInteger.test(value) && (lastChar === "w")) { 465 466 // If width and density are not both absent, then let error be yes. 467 if (w || d) {pError = true;} 468 469 // Apply the rules for parsing non-negative integers to the descriptor. 470 // If the result is zero, let error be yes. 471 // Otherwise, let width be the result. 472 if (intVal === 0) {pError = true;} else {w = intVal;} 473 474 // If the descriptor consists of a valid floating-point number followed by 475 // a U+0078 LATIN SMALL LETTER X character 476 } else if (regexFloatingPoint.test(value) && (lastChar === "x")) { 477 478 // If width, density and future-compat-h are not all absent, then let error 479 // be yes. 480 if (w || d || h) {pError = true;} 481 482 // Apply the rules for parsing floating-point number values to the descriptor. 483 // If the result is less than zero, let error be yes. Otherwise, let density 484 // be the result. 485 if (floatVal < 0) {pError = true;} else {d = floatVal;} 486 487 // If the descriptor consists of a valid non-negative integer followed by 488 // a U+0068 LATIN SMALL LETTER H character 489 } else if (regexNonNegativeInteger.test(value) && (lastChar === "h")) { 490 491 // If height and density are not both absent, then let error be yes. 492 if (h || d) {pError = true;} 493 494 // Apply the rules for parsing non-negative integers to the descriptor. 495 // If the result is zero, let error be yes. Otherwise, let future-compat-h 496 // be the result. 497 if (intVal === 0) {pError = true;} else {h = intVal;} 498 499 // Anything else, Let error be yes. 500 } else {pError = true;} 501 } // (close step 13 for loop) 502 503 // 15. If error is still no, then append a new image source to candidates whose 504 // URL is url, associated with a width width if not absent and a pixel 505 // density density if not absent. Otherwise, there is a parse error. 506 if (!pError) { 507 candidate.url = url; 508 509 if (w) { candidate.w = w;} 510 if (d) { candidate.d = d;} 511 if (h) { candidate.h = h;} 512 if (!h && !d && !w) {candidate.d = 1;} 513 if (candidate.d === 1) {set.has1x = true;} 514 candidate.set = set; 515 516 candidates.push(candidate); 517 } 518 } // (close parseDescriptors fn) 519 520 /** 521 * Tokenizes descriptor properties prior to parsing 522 * Returns undefined. 523 * (Again, this fn is defined before it is used, in order to pass JSHINT. 524 * Unfortunately this breaks the logical sequencing of the spec comments. :/ ) 525 */ 526 function tokenize() { 527 528 // 8.1. Descriptor tokeniser: Skip whitespace 529 collectCharacters(regexLeadingSpaces); 530 531 // 8.2. Let current descriptor be the empty string. 532 currentDescriptor = ""; 533 534 // 8.3. Let state be in descriptor. 535 state = "in descriptor"; 536 537 while (true) { 538 539 // 8.4. Let c be the character at position. 540 c = input.charAt(pos); 541 542 // Do the following depending on the value of state. 543 // For the purpose of this step, "EOF" is a special character representing 544 // that position is past the end of input. 545 546 // In descriptor 547 if (state === "in descriptor") { 548 // Do the following, depending on the value of c: 549 550 // Space character 551 // If current descriptor is not empty, append current descriptor to 552 // descriptors and let current descriptor be the empty string. 553 // Set state to after descriptor. 554 if (isSpace(c)) { 555 if (currentDescriptor) { 556 descriptors.push(currentDescriptor); 557 currentDescriptor = ""; 558 state = "after descriptor"; 559 } 560 561 // U+002C COMMA (,) 562 // Advance position to the next character in input. If current descriptor 563 // is not empty, append current descriptor to descriptors. Jump to the step 564 // labeled descriptor parser. 565 } else if (c === ",") { 566 pos += 1; 567 if (currentDescriptor) { 568 descriptors.push(currentDescriptor); 569 } 570 parseDescriptors(); 571 return; 572 573 // U+0028 LEFT PARENTHESIS (() 574 // Append c to current descriptor. Set state to in parens. 575 } else if (c === "\u0028") { 576 currentDescriptor = currentDescriptor + c; 577 state = "in parens"; 578 579 // EOF 580 // If current descriptor is not empty, append current descriptor to 581 // descriptors. Jump to the step labeled descriptor parser. 582 } else if (c === "") { 583 if (currentDescriptor) { 584 descriptors.push(currentDescriptor); 585 } 586 parseDescriptors(); 587 return; 588 589 // Anything else 590 // Append c to current descriptor. 591 } else { 592 currentDescriptor = currentDescriptor + c; 593 } 594 // (end "in descriptor" 595 596 // In parens 597 } else if (state === "in parens") { 598 599 // U+0029 RIGHT PARENTHESIS ()) 600 // Append c to current descriptor. Set state to in descriptor. 601 if (c === ")") { 602 currentDescriptor = currentDescriptor + c; 603 state = "in descriptor"; 604 605 // EOF 606 // Append current descriptor to descriptors. Jump to the step labeled 607 // descriptor parser. 608 } else if (c === "") { 609 descriptors.push(currentDescriptor); 610 parseDescriptors(); 611 return; 612 613 // Anything else 614 // Append c to current descriptor. 615 } else { 616 currentDescriptor = currentDescriptor + c; 617 } 618 619 // After descriptor 620 } else if (state === "after descriptor") { 621 622 // Do the following, depending on the value of c: 623 // Space character: Stay in this state. 624 if (isSpace(c)) { 625 626 // EOF: Jump to the step labeled descriptor parser. 627 } else if (c === "") { 628 parseDescriptors(); 629 return; 630 631 // Anything else 632 // Set state to in descriptor. Set position to the previous character in input. 633 } else { 634 state = "in descriptor"; 635 pos -= 1; 636 637 } 638 } 639 640 // Advance position to the next character in input. 641 pos += 1; 642 643 // Repeat this step. 644 } // (close while true loop) 645 } 646 647 // 4. Splitting loop: Collect a sequence of characters that are space 648 // characters or U+002C COMMA characters. If any U+002C COMMA characters 649 // were collected, that is a parse error. 650 while (true) { 651 collectCharacters(regexLeadingCommasOrSpaces); 652 653 // 5. If position is past the end of input, return candidates and abort these steps. 654 if (pos >= inputLength) { 655 return candidates; // (we're done, this is the sole return path) 656 } 657 658 // 6. Collect a sequence of characters that are not space characters, 659 // and let that be url. 660 url = collectCharacters(regexLeadingNotSpaces); 661 662 // 7. Let descriptors be a new empty list. 663 descriptors = []; 664 665 // 8. If url ends with a U+002C COMMA character (,), follow these substeps: 666 // (1). Remove all trailing U+002C COMMA characters from url. If this removed 667 // more than one character, that is a parse error. 668 if (url.slice(-1) === ",") { 669 url = url.replace(regexTrailingCommas, ""); 670 // (Jump ahead to step 9 to skip tokenization and just push the candidate). 671 parseDescriptors(); 672 673 // Otherwise, follow these substeps: 674 } else { 675 tokenize(); 676 } // (close else of step 8) 677 678 // 16. Return to the step labeled splitting loop. 679 } // (Close of big while loop.) 680 } 681 682 /* 683 * Sizes Parser 684 * 685 * By Alex Bell | MIT License 686 * 687 * Non-strict but accurate and lightweight JS Parser for the string value <img sizes="here"> 688 * 689 * Reference algorithm at: 690 * https://html.spec.whatwg.org/multipage/embedded-content.html#parse-a-sizes-attribute 691 * 692 * Most comments are copied in directly from the spec 693 * (except for comments in parens). 694 * 695 * Grammar is: 696 * <source-size-list> = <source-size># [ , <source-size-value> ]? | <source-size-value> 697 * <source-size> = <media-condition> <source-size-value> 698 * <source-size-value> = <length> 699 * http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-sizes 700 * 701 * E.g. "(max-width: 30em) 100vw, (max-width: 50em) 70vw, 100vw" 702 * or "(min-width: 30em), calc(30vw - 15px)" or just "30vw" 703 * 704 * Returns the first valid <css-length> with a media condition that evaluates to true, 705 * or "100vw" if all valid media conditions evaluate to false. 706 * 707 */ 708 709 function parseSizes(strValue) { 710 711 // (Percentage CSS lengths are not allowed in this case, to avoid confusion: 712 // https://html.spec.whatwg.org/multipage/embedded-content.html#valid-source-size-list 713 // CSS allows a single optional plus or minus sign: 714 // http://www.w3.org/TR/CSS2/syndata.html#numbers 715 // CSS is ASCII case-insensitive: 716 // http://www.w3.org/TR/CSS2/syndata.html#characters ) 717 // Spec allows exponential notation for <number> type: 718 // http://dev.w3.org/csswg/css-values/#numbers 719 var regexCssLengthWithUnits = /^(?:[+-]?[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i; 720 721 // (This is a quick and lenient test. Because of optional unlimited-depth internal 722 // grouping parens and strict spacing rules, this could get very complicated.) 723 var regexCssCalc = /^calc\((?:[0-9a-z \.\+\-\*\/\(\)]+)\)$/i; 724 725 var i; 726 var unparsedSizesList; 727 var unparsedSizesListLength; 728 var unparsedSize; 729 var lastComponentValue; 730 var size; 731 732 // UTILITY FUNCTIONS 733 734 // (Toy CSS parser. The goals here are: 735 // 1) expansive test coverage without the weight of a full CSS parser. 736 // 2) Avoiding regex wherever convenient. 737 // Quick tests: http://jsfiddle.net/gtntL4gr/3/ 738 // Returns an array of arrays.) 739 function parseComponentValues(str) { 740 var chrctr; 741 var component = ""; 742 var componentArray = []; 743 var listArray = []; 744 var parenDepth = 0; 745 var pos = 0; 746 var inComment = false; 747 748 function pushComponent() { 749 if (component) { 750 componentArray.push(component); 751 component = ""; 752 } 753 } 754 755 function pushComponentArray() { 756 if (componentArray[0]) { 757 listArray.push(componentArray); 758 componentArray = []; 759 } 760 } 761 762 // (Loop forwards from the beginning of the string.) 763 while (true) { 764 chrctr = str.charAt(pos); 765 766 if (chrctr === "") { // ( End of string reached.) 767 pushComponent(); 768 pushComponentArray(); 769 return listArray; 770 } else if (inComment) { 771 if ((chrctr === "*") && (str[pos + 1] === "/")) { // (At end of a comment.) 772 inComment = false; 773 pos += 2; 774 pushComponent(); 775 continue; 776 } else { 777 pos += 1; // (Skip all characters inside comments.) 778 continue; 779 } 780 } else if (isSpace(chrctr)) { 781 // (If previous character in loop was also a space, or if 782 // at the beginning of the string, do not add space char to 783 // component.) 784 if ( (str.charAt(pos - 1) && isSpace( str.charAt(pos - 1) ) ) || !component ) { 785 pos += 1; 786 continue; 787 } else if (parenDepth === 0) { 788 pushComponent(); 789 pos +=1; 790 continue; 791 } else { 792 // (Replace any space character with a plain space for legibility.) 793 chrctr = " "; 794 } 795 } else if (chrctr === "(") { 796 parenDepth += 1; 797 } else if (chrctr === ")") { 798 parenDepth -= 1; 799 } else if (chrctr === ",") { 800 pushComponent(); 801 pushComponentArray(); 802 pos += 1; 803 continue; 804 } else if ( (chrctr === "/") && (str.charAt(pos + 1) === "*") ) { 805 inComment = true; 806 pos += 2; 807 continue; 808 } 809 810 component = component + chrctr; 811 pos += 1; 812 } 813 } 814 815 function isValidNonNegativeSourceSizeValue(s) { 816 if (regexCssLengthWithUnits.test(s) && (parseFloat(s) >= 0)) {return true;} 817 if (regexCssCalc.test(s)) {return true;} 818 // ( http://www.w3.org/TR/CSS2/syndata.html#numbers says: 819 // "-0 is equivalent to 0 and is not a negative number." which means that 820 // unitless zero and unitless negative zero must be accepted as special cases.) 821 if ((s === "0") || (s === "-0") || (s === "+0")) {return true;} 822 return false; 823 } 824 825 // When asked to parse a sizes attribute from an element, parse a 826 // comma-separated list of component values from the value of the element's 827 // sizes attribute (or the empty string, if the attribute is absent), and let 828 // unparsed sizes list be the result. 829 // http://dev.w3.org/csswg/css-syntax/#parse-comma-separated-list-of-component-values 830 831 unparsedSizesList = parseComponentValues(strValue); 832 unparsedSizesListLength = unparsedSizesList.length; 833 834 // For each unparsed size in unparsed sizes list: 835 for (i = 0; i < unparsedSizesListLength; i++) { 836 unparsedSize = unparsedSizesList[i]; 837 838 // 1. Remove all consecutive <whitespace-token>s from the end of unparsed size. 839 // ( parseComponentValues() already omits spaces outside of parens. ) 840 841 // If unparsed size is now empty, that is a parse error; continue to the next 842 // iteration of this algorithm. 843 // ( parseComponentValues() won't push an empty array. ) 844 845 // 2. If the last component value in unparsed size is a valid non-negative 846 // <source-size-value>, let size be its value and remove the component value 847 // from unparsed size. Any CSS function other than the calc() function is 848 // invalid. Otherwise, there is a parse error; continue to the next iteration 849 // of this algorithm. 850 // http://dev.w3.org/csswg/css-syntax/#parse-component-value 851 lastComponentValue = unparsedSize[unparsedSize.length - 1]; 852 853 if (isValidNonNegativeSourceSizeValue(lastComponentValue)) { 854 size = lastComponentValue; 855 unparsedSize.pop(); 856 } else { 857 continue; 858 } 859 860 // 3. Remove all consecutive <whitespace-token>s from the end of unparsed 861 // size. If unparsed size is now empty, return size and exit this algorithm. 862 // If this was not the last item in unparsed sizes list, that is a parse error. 863 if (unparsedSize.length === 0) { 864 return size; 865 } 866 867 // 4. Parse the remaining component values in unparsed size as a 868 // <media-condition>. If it does not parse correctly, or it does parse 869 // correctly but the <media-condition> evaluates to false, continue to the 870 // next iteration of this algorithm. 871 // (Parsing all possible compound media conditions in JS is heavy, complicated, 872 // and the payoff is unclear. Is there ever an situation where the 873 // media condition parses incorrectly but still somehow evaluates to true? 874 // Can we just rely on the browser/polyfill to do it?) 875 unparsedSize = unparsedSize.join(" "); 876 if (!(pf.matchesMedia( unparsedSize ) ) ) { 877 continue; 878 } 879 880 // 5. Return size and exit this algorithm. 881 return size; 882 } 883 884 // If the above algorithm exhausts unparsed sizes list without returning a 885 // size value, return 100vw. 886 return "100vw"; 887 } 888 889 // namespace 890 pf.ns = ("pf" + new Date().getTime()).substr(0, 9); 891 892 // srcset support test 893 pf.supSrcset = "srcset" in image; 894 pf.supSizes = "sizes" in image; 895 pf.supPicture = !!window.HTMLPictureElement; 896 897 // UC browser does claim to support srcset and picture, but not sizes, 898 // this extended test reveals the browser does support nothing 899 if (pf.supSrcset && pf.supPicture && !pf.supSizes) { 900 (function(image2) { 901 image.srcset = "data:,a"; 902 image2.src = "data:,a"; 903 pf.supSrcset = image.complete === image2.complete; 904 pf.supPicture = pf.supSrcset && pf.supPicture; 905 })(document.createElement("img")); 906 } 907 908 // Safari9 has basic support for sizes, but does't expose the `sizes` idl attribute 909 if (pf.supSrcset && !pf.supSizes) { 910 911 (function() { 912 var width2 = "data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw=="; 913 var width1 = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; 914 var img = document.createElement("img"); 915 var test = function() { 916 var width = img.width; 917 918 if (width === 2) { 919 pf.supSizes = true; 920 } 921 922 alwaysCheckWDescriptor = pf.supSrcset && !pf.supSizes; 923 924 isSupportTestReady = true; 925 // force async 926 setTimeout(picturefill); 927 }; 928 929 img.onload = test; 930 img.onerror = test; 931 img.setAttribute("sizes", "9px"); 932 933 img.srcset = width1 + " 1w," + width2 + " 9w"; 934 img.src = width1; 935 })(); 936 937 } else { 938 isSupportTestReady = true; 939 } 940 941 // using pf.qsa instead of dom traversing does scale much better, 942 // especially on sites mixing responsive and non-responsive images 943 pf.selShort = "picture>img,img[srcset]"; 944 pf.sel = pf.selShort; 945 pf.cfg = cfg; 946 947 /** 948 * Shortcut property for `devicePixelRatio` ( for easy overriding in tests ) 949 */ 950 pf.DPR = (DPR || 1 ); 951 pf.u = units; 952 953 // container of supported mime types that one might need to qualify before using 954 pf.types = types; 955 956 pf.setSize = noop; 957 958 /** 959 * Gets a string and returns the absolute URL 960 * @param src 961 * @returns {String} absolute URL 962 */ 963 964 pf.makeUrl = memoize(function(src) { 965 anchor.href = src; 966 return anchor.href; 967 }); 968 969 /** 970 * Gets a DOM element or document and a selctor and returns the found matches 971 * Can be extended with jQuery/Sizzle for IE7 support 972 * @param context 973 * @param sel 974 * @returns {NodeList|Array} 975 */ 976 pf.qsa = function(context, sel) { 977 return ( "querySelector" in context ) ? context.querySelectorAll(sel) : []; 978 }; 979 980 /** 981 * Shortcut method for matchMedia ( for easy overriding in tests ) 982 * wether native or pf.mMQ is used will be decided lazy on first call 983 * @returns {boolean} 984 */ 985 pf.matchesMedia = function() { 986 if ( window.matchMedia && (matchMedia( "(min-width: 0.1em)" ) || {}).matches ) { 987 pf.matchesMedia = function( media ) { 988 return !media || ( matchMedia( media ).matches ); 989 }; 990 } else { 991 pf.matchesMedia = pf.mMQ; 992 } 993 994 return pf.matchesMedia.apply( this, arguments ); 995 }; 996 997 /** 998 * A simplified matchMedia implementation for IE8 and IE9 999 * handles only min-width/max-width with px or em values 1000 * @param media 1001 * @returns {boolean} 1002 */ 1003 pf.mMQ = function( media ) { 1004 return media ? evalCSS(media) : true; 1005 }; 1006 1007 /** 1008 * Returns the calculated length in css pixel from the given sourceSizeValue 1009 * http://dev.w3.org/csswg/css-values-3/#length-value 1010 * intended Spec mismatches: 1011 * * Does not check for invalid use of CSS functions 1012 * * Does handle a computed length of 0 the same as a negative and therefore invalid value 1013 * @param sourceSizeValue 1014 * @returns {Number} 1015 */ 1016 pf.calcLength = function( sourceSizeValue ) { 1017 1018 var value = evalCSS(sourceSizeValue, true) || false; 1019 if (value < 0) { 1020 value = false; 1021 } 1022 1023 return value; 1024 }; 1025 1026 /** 1027 * Takes a type string and checks if its supported 1028 */ 1029 1030 pf.supportsType = function( type ) { 1031 return ( type ) ? types[ type ] : true; 1032 }; 1033 1034 /** 1035 * Parses a sourceSize into mediaCondition (media) and sourceSizeValue (length) 1036 * @param sourceSizeStr 1037 * @returns {*} 1038 */ 1039 pf.parseSize = memoize(function( sourceSizeStr ) { 1040 var match = ( sourceSizeStr || "" ).match(regSize); 1041 return { 1042 media: match && match[1], 1043 length: match && match[2] 1044 }; 1045 }); 1046 1047 pf.parseSet = function( set ) { 1048 if ( !set.cands ) { 1049 set.cands = parseSrcset(set.srcset, set); 1050 } 1051 return set.cands; 1052 }; 1053 1054 /** 1055 * returns 1em in css px for html/body default size 1056 * function taken from respondjs 1057 * @returns {*|number} 1058 */ 1059 pf.getEmValue = function() { 1060 var body; 1061 if ( !eminpx && (body = document.body) ) { 1062 var div = document.createElement( "div" ), 1063 originalHTMLCSS = docElem.style.cssText, 1064 originalBodyCSS = body.style.cssText; 1065 1066 div.style.cssText = baseStyle; 1067 1068 // 1em in a media query is the value of the default font size of the browser 1069 // reset docElem and body to ensure the correct value is returned 1070 docElem.style.cssText = fsCss; 1071 body.style.cssText = fsCss; 1072 1073 body.appendChild( div ); 1074 eminpx = div.offsetWidth; 1075 body.removeChild( div ); 1076 1077 //also update eminpx before returning 1078 eminpx = parseFloat( eminpx, 10 ); 1079 1080 // restore the original values 1081 docElem.style.cssText = originalHTMLCSS; 1082 body.style.cssText = originalBodyCSS; 1083 1084 } 1085 return eminpx || 16; 1086 }; 1087 1088 /** 1089 * Takes a string of sizes and returns the width in pixels as a number 1090 */ 1091 pf.calcListLength = function( sourceSizeListStr ) { 1092 // Split up source size list, ie ( max-width: 30em ) 100%, ( max-width: 50em ) 50%, 33% 1093 // 1094 // or (min-width:30em) calc(30% - 15px) 1095 if ( !(sourceSizeListStr in sizeLengthCache) || cfg.uT ) { 1096 var winningLength = pf.calcLength( parseSizes( sourceSizeListStr ) ); 1097 1098 sizeLengthCache[ sourceSizeListStr ] = !winningLength ? units.width : winningLength; 1099 } 1100 1101 return sizeLengthCache[ sourceSizeListStr ]; 1102 }; 1103 1104 /** 1105 * Takes a candidate object with a srcset property in the form of url/ 1106 * ex. "images/pic-medium.png 1x, images/pic-medium-2x.png 2x" or 1107 * "images/pic-medium.png 400w, images/pic-medium-2x.png 800w" or 1108 * "images/pic-small.png" 1109 * Get an array of image candidates in the form of 1110 * {url: "/foo/bar.png", resolution: 1} 1111 * where resolution is http://dev.w3.org/csswg/css-values-3/#resolution-value 1112 * If sizes is specified, res is calculated 1113 */ 1114 pf.setRes = function( set ) { 1115 var candidates; 1116 if ( set ) { 1117 1118 candidates = pf.parseSet( set ); 1119 1120 for ( var i = 0, len = candidates.length; i < len; i++ ) { 1121 setResolution( candidates[ i ], set.sizes ); 1122 } 1123 } 1124 return candidates; 1125 }; 1126 1127 pf.setRes.res = setResolution; 1128 1129 pf.applySetCandidate = function( candidates, img ) { 1130 if ( !candidates.length ) {return;} 1131 var candidate, 1132 i, 1133 j, 1134 length, 1135 bestCandidate, 1136 curSrc, 1137 curCan, 1138 candidateSrc, 1139 abortCurSrc; 1140 1141 var imageData = img[ pf.ns ]; 1142 var dpr = pf.DPR; 1143 1144 curSrc = imageData.curSrc || img[curSrcProp]; 1145 1146 curCan = imageData.curCan || setSrcToCur(img, curSrc, candidates[0].set); 1147 1148 // if we have a current source, we might either become lazy or give this source some advantage 1149 if ( curCan && curCan.set === candidates[ 0 ].set ) { 1150 1151 // if browser can abort image request and the image has a higher pixel density than needed 1152 // and this image isn't downloaded yet, we skip next part and try to save bandwidth 1153 abortCurSrc = (supportAbort && !img.complete && curCan.res - 0.1 > dpr); 1154 1155 if ( !abortCurSrc ) { 1156 curCan.cached = true; 1157 1158 // if current candidate is "best", "better" or "okay", 1159 // set it to bestCandidate 1160 if ( curCan.res >= dpr ) { 1161 bestCandidate = curCan; 1162 } 1163 } 1164 } 1165 1166 if ( !bestCandidate ) { 1167 1168 candidates.sort( ascendingSort ); 1169 1170 length = candidates.length; 1171 bestCandidate = candidates[ length - 1 ]; 1172 1173 for ( i = 0; i < length; i++ ) { 1174 candidate = candidates[ i ]; 1175 if ( candidate.res >= dpr ) { 1176 j = i - 1; 1177 1178 // we have found the perfect candidate, 1179 // but let's improve this a little bit with some assumptions ;-) 1180 if (candidates[ j ] && 1181 (abortCurSrc || curSrc !== pf.makeUrl( candidate.url )) && 1182 chooseLowRes(candidates[ j ].res, candidate.res, dpr, candidates[ j ].cached)) { 1183 1184 bestCandidate = candidates[ j ]; 1185 1186 } else { 1187 bestCandidate = candidate; 1188 } 1189 break; 1190 } 1191 } 1192 } 1193 1194 if ( bestCandidate ) { 1195 1196 candidateSrc = pf.makeUrl( bestCandidate.url ); 1197 1198 imageData.curSrc = candidateSrc; 1199 imageData.curCan = bestCandidate; 1200 1201 if ( candidateSrc !== curSrc ) { 1202 pf.setSrc( img, bestCandidate ); 1203 } 1204 pf.setSize( img ); 1205 } 1206 }; 1207 1208 pf.setSrc = function( img, bestCandidate ) { 1209 var origWidth; 1210 img.src = bestCandidate.url; 1211 1212 // although this is a specific Safari issue, we don't want to take too much different code paths 1213 if ( bestCandidate.set.type === "image/svg+xml" ) { 1214 origWidth = img.style.width; 1215 img.style.width = (img.offsetWidth + 1) + "px"; 1216 1217 // next line only should trigger a repaint 1218 // if... is only done to trick dead code removal 1219 if ( img.offsetWidth + 1 ) { 1220 img.style.width = origWidth; 1221 } 1222 } 1223 }; 1224 1225 pf.getSet = function( img ) { 1226 var i, set, supportsType; 1227 var match = false; 1228 var sets = img [ pf.ns ].sets; 1229 1230 for ( i = 0; i < sets.length && !match; i++ ) { 1231 set = sets[i]; 1232 1233 if ( !set.srcset || !pf.matchesMedia( set.media ) || !(supportsType = pf.supportsType( set.type )) ) { 1234 continue; 1235 } 1236 1237 if ( supportsType === "pending" ) { 1238 set = supportsType; 1239 } 1240 1241 match = set; 1242 break; 1243 } 1244 1245 return match; 1246 }; 1247 1248 pf.parseSets = function( element, parent, options ) { 1249 var srcsetAttribute, imageSet, isWDescripor, srcsetParsed; 1250 1251 var hasPicture = parent && parent.nodeName.toUpperCase() === "PICTURE"; 1252 var imageData = element[ pf.ns ]; 1253 1254 if ( imageData.src === undefined || options.src ) { 1255 imageData.src = getImgAttr.call( element, "src" ); 1256 if ( imageData.src ) { 1257 setImgAttr.call( element, srcAttr, imageData.src ); 1258 } else { 1259 removeImgAttr.call( element, srcAttr ); 1260 } 1261 } 1262 1263 if ( imageData.srcset === undefined || options.srcset || !pf.supSrcset || element.srcset ) { 1264 srcsetAttribute = getImgAttr.call( element, "srcset" ); 1265 imageData.srcset = srcsetAttribute; 1266 srcsetParsed = true; 1267 } 1268 1269 imageData.sets = []; 1270 1271 if ( hasPicture ) { 1272 imageData.pic = true; 1273 getAllSourceElements( parent, imageData.sets ); 1274 } 1275 1276 if ( imageData.srcset ) { 1277 imageSet = { 1278 srcset: imageData.srcset, 1279 sizes: getImgAttr.call( element, "sizes" ) 1280 }; 1281 1282 imageData.sets.push( imageSet ); 1283 1284 isWDescripor = (alwaysCheckWDescriptor || imageData.src) && regWDesc.test(imageData.srcset || ""); 1285 1286 // add normal src as candidate, if source has no w descriptor 1287 if ( !isWDescripor && imageData.src && !getCandidateForSrc(imageData.src, imageSet) && !imageSet.has1x ) { 1288 imageSet.srcset += ", " + imageData.src; 1289 imageSet.cands.push({ 1290 url: imageData.src, 1291 d: 1, 1292 set: imageSet 1293 }); 1294 } 1295 1296 } else if ( imageData.src ) { 1297 imageData.sets.push( { 1298 srcset: imageData.src, 1299 sizes: null 1300 } ); 1301 } 1302 1303 imageData.curCan = null; 1304 imageData.curSrc = undefined; 1305 1306 // if img has picture or the srcset was removed or has a srcset and does not support srcset at all 1307 // or has a w descriptor (and does not support sizes) set support to false to evaluate 1308 imageData.supported = !( hasPicture || ( imageSet && !pf.supSrcset ) || (isWDescripor && !pf.supSizes) ); 1309 1310 if ( srcsetParsed && pf.supSrcset && !imageData.supported ) { 1311 if ( srcsetAttribute ) { 1312 setImgAttr.call( element, srcsetAttr, srcsetAttribute ); 1313 element.srcset = ""; 1314 } else { 1315 removeImgAttr.call( element, srcsetAttr ); 1316 } 1317 } 1318 1319 if (imageData.supported && !imageData.srcset && ((!imageData.src && element.src) || element.src !== pf.makeUrl(imageData.src))) { 1320 if (imageData.src === null) { 1321 element.removeAttribute("src"); 1322 } else { 1323 element.src = imageData.src; 1324 } 1325 } 1326 1327 imageData.parsed = true; 1328 }; 1329 1330 pf.fillImg = function(element, options) { 1331 var imageData; 1332 var extreme = options.reselect || options.reevaluate; 1333 1334 // expando for caching data on the img 1335 if ( !element[ pf.ns ] ) { 1336 element[ pf.ns ] = {}; 1337 } 1338 1339 imageData = element[ pf.ns ]; 1340 1341 // if the element has already been evaluated, skip it 1342 // unless `options.reevaluate` is set to true ( this, for example, 1343 // is set to true when running `picturefill` on `resize` ). 1344 if ( !extreme && imageData.evaled === evalId ) { 1345 return; 1346 } 1347 1348 if ( !imageData.parsed || options.reevaluate ) { 1349 pf.parseSets( element, element.parentNode, options ); 1350 } 1351 1352 if ( !imageData.supported ) { 1353 applyBestCandidate( element ); 1354 } else { 1355 imageData.evaled = evalId; 1356 } 1357 }; 1358 1359 pf.setupRun = function() { 1360 if ( !alreadyRun || isVwDirty || (DPR !== window.devicePixelRatio) ) { 1361 updateMetrics(); 1362 } 1363 }; 1364 1365 // If picture is supported, well, that's awesome. 1366 if ( pf.supPicture ) { 1367 picturefill = noop; 1368 pf.fillImg = noop; 1369 } else { 1370 1371 // Set up picture polyfill by polling the document 1372 (function() { 1373 var isDomReady; 1374 var regReady = window.attachEvent ? /d$|^c/ : /d$|^c|^i/; 1375 1376 var run = function() { 1377 var readyState = document.readyState || ""; 1378 1379 timerId = setTimeout(run, readyState === "loading" ? 200 : 999); 1380 if ( document.body ) { 1381 pf.fillImgs(); 1382 isDomReady = isDomReady || regReady.test(readyState); 1383 if ( isDomReady ) { 1384 clearTimeout( timerId ); 1385 } 1386 1387 } 1388 }; 1389 1390 var timerId = setTimeout(run, document.body ? 9 : 99); 1391 1392 // Also attach picturefill on resize and readystatechange 1393 // http://modernjavascript.blogspot.com/2013/08/building-better-debounce.html 1394 var debounce = function(func, wait) { 1395 var timeout, timestamp; 1396 var later = function() { 1397 var last = (new Date()) - timestamp; 1398 1399 if (last < wait) { 1400 timeout = setTimeout(later, wait - last); 1401 } else { 1402 timeout = null; 1403 func(); 1404 } 1405 }; 1406 1407 return function() { 1408 timestamp = new Date(); 1409 1410 if (!timeout) { 1411 timeout = setTimeout(later, wait); 1412 } 1413 }; 1414 }; 1415 var lastClientWidth = docElem.clientHeight; 1416 var onResize = function() { 1417 isVwDirty = Math.max(window.innerWidth || 0, docElem.clientWidth) !== units.width || docElem.clientHeight !== lastClientWidth; 1418 lastClientWidth = docElem.clientHeight; 1419 if ( isVwDirty ) { 1420 pf.fillImgs(); 1421 } 1422 }; 1423 1424 on( window, "resize", debounce(onResize, 99 ) ); 1425 on( document, "readystatechange", run ); 1426 })(); 1427 } 1428 1429 pf.picturefill = picturefill; 1430 //use this internally for easy monkey patching/performance testing 1431 pf.fillImgs = picturefill; 1432 pf.teardownRun = noop; 1433 1434 /* expose methods for testing */ 1435 picturefill._ = pf; 1436 1437 window.picturefillCFG = { 1438 pf: pf, 1439 push: function(args) { 1440 var name = args.shift(); 1441 if (typeof pf[name] === "function") { 1442 pf[name].apply(pf, args); 1443 } else { 1444 cfg[name] = args[0]; 1445 if (alreadyRun) { 1446 pf.fillImgs( { reselect: true } ); 1447 } 1448 } 1449 } 1450 }; 1451 1452 while (setOptions && setOptions.length) { 1453 window.picturefillCFG.push(setOptions.shift()); 1454 } 1455 1456 /* expose picturefill */ 1457 window.picturefill = picturefill; 1458 1459 /* expose picturefill */ 1460 if ( typeof module === "object" && typeof module.exports === "object" ) { 1461 // CommonJS, just export 1462 module.exports = picturefill; 1463 } else if ( typeof define === "function" && define.amd ) { 1464 // AMD support 1465 define( "picturefill", function() { return picturefill; } ); 1466 } 1467 1468 // IE8 evals this sync, so it must be the last thing we do 1469 if ( !pf.supPicture ) { 1470 types[ "image/webp" ] = detectTypeSupport("image/webp", "data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA==" ); 1471 } 1472 1473} )( window, document );
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.