(img)
| 25681 | } |
| 25682 | |
| 25683 | function findPic(img){ |
| 25684 | var imgPN=img; |
| 25685 | var imgPA,imgPE=[]; |
| 25686 | while(imgPN=imgPN.parentNode || imgPN.host){ |
| 25687 | if(imgPN.nodeName.toUpperCase()=='A'){ |
| 25688 | imgPA=imgPN; |
| 25689 | break; |
| 25690 | } |
| 25691 | } |
| 25692 | imgPN=img; |
| 25693 | while(imgPN=imgPN.parentNode || imgPN.host){ |
| 25694 | if(imgPN.nodeName.toUpperCase()=='BODY'){ |
| 25695 | break; |
| 25696 | }else{ |
| 25697 | imgPE.push(imgPN); |
| 25698 | } |
| 25699 | } |
| 25700 | |
| 25701 | var iPASrc=imgPA? imgPA.href : ''; |
| 25702 | //base64字符串过长导致正则匹配卡死浏览器 |
| 25703 | var base64Img=/^data:/i.test(img.src); |
| 25704 | var src, // 大图地址 |
| 25705 | srcs, // 备用的大图地址 |
| 25706 | type, // 类别 |
| 25707 | noActual = false, //没有原图 |
| 25708 | imgSrc = img.currentSrc||img.src||img.dataset.lazySrc, // img 节点的 src |
| 25709 | xhr, |
| 25710 | description; // 图片的注释 |
| 25711 | var imgCStyle = unsafeWindow.getComputedStyle(img); |
| 25712 | if (/^link$/i.test(img.nodeName)) { |
| 25713 | imgCStyle = {height:64, width:64}; |
| 25714 | } |
| 25715 | if (!/IMG/i.test(img.nodeName) && imgCStyle && imgCStyle.backgroundImage && imgCStyle.backgroundImage != "none") { |
| 25716 | let sh = imgCStyle.height, sw = imgCStyle.width; |
| 25717 | if (!img.offsetWidth) sw = 10; |
| 25718 | if (!img.offsetHeight) sh = 10; |
| 25719 | if (imgCStyle.backgroundRepeatX == "repeat") { |
| 25720 | sw = 10; |
| 25721 | } |
| 25722 | if (imgCStyle.backgroundRepeatY == "repeat") { |
| 25723 | sh = 10; |
| 25724 | } |
| 25725 | imgCStyle = {height:sh, width:sw}; |
| 25726 | } |
| 25727 | var imgCS = { |
| 25728 | h: parseFloat(imgCStyle.height) || img.height || img.offsetHeight, |
| 25729 | w: parseFloat(imgCStyle.width) || img.width || img.offsetWidth, |
| 25730 | }; |
| 25731 | if (imgCS.h === 0 && imgCS.w === 0) { |
| 25732 | for (let i = 0; i < imgPE.length; i++) { |
| 25733 | if (imgPE[i].offsetHeight) { |
| 25734 | imgCS = { |
| 25735 | h: imgPE[i].offsetHeight, |
| 25736 | w: imgPE[i].offsetWidth |
| 25737 | }; |
| 25738 | break; |
| 25739 | } |
| 25740 | } |
no test coverage detected