@yorkjs/web-error
Advanced tools
Comparing version 1.0.0 to 1.0.1
/** | ||
* web-error.js v1.0.0 | ||
* web-error.js v1.0.1 | ||
* (c) 2021-2022 shushu2013 | ||
@@ -49,3 +49,8 @@ * Released under the MIT License. | ||
}; | ||
config.reportError(msgObj); | ||
// 只上报资源类型的错误 | ||
const target = event.target || event.srcElement; | ||
const isHTMLElement = target && target instanceof HTMLElement; | ||
if (isHTMLElement) { | ||
config.reportError(msgObj); | ||
} | ||
} | ||
@@ -57,3 +62,6 @@ catch (err) { | ||
// event.preventDefault() | ||
}, true); | ||
}, | ||
// 当一项资源(如<img>或<script>)加载失败,该 error 不会冒泡到 window,可在捕获阶段捕获 | ||
// true 代表在捕获阶段调用,false 代表在冒泡阶段 | ||
true); | ||
// 当 Promise 被 reject 且没有 reject 处理器的时候 | ||
@@ -95,5 +103,5 @@ // 会触发 unhandledrejection 事件 | ||
*/ | ||
const version = "1.0.0"; | ||
const version = "1.0.1"; | ||
export { init, sendBeacon, sendImage, version }; | ||
//# sourceMappingURL=web-error.esm.js.map |
@@ -1,2 +0,2 @@ | ||
function n(n,o){let r=new Image;r.onload=r.onerror=function(){r=r.onload=r.onerror=null},r.src=`${n}?${o}`}function o(n,o){navigator.sendBeacon(n,o)}function r(n){!function(n){const o=window.onerror;window.onerror=function(r,e,t,c,i){o&&o(r,e,t,c,i);try{const o={url:location.href,type:1,error:r.toString(),file:e,line:t,column:c};n.reportError(o)}catch(n){}return!1},window.addEventListener("error",(function(o){try{const r={url:location.href,type:2,error:o.message,file:o.filename,line:o.lineno,column:o.colno};n.reportError(r)}catch(n){}}),!0)}(n)}const e="1.0.0";export{r as init,o as sendBeacon,n as sendImage,e as version}; | ||
function n(n,o){let r=new Image;r.onload=r.onerror=function(){r=r.onload=r.onerror=null},r.src=`${n}?${o}`}function o(n,o){navigator.sendBeacon(n,o)}function r(n){!function(n){const o=window.onerror;window.onerror=function(r,e,t,c,i){o&&o(r,e,t,c,i);try{const o={url:location.href,type:1,error:r.toString(),file:e,line:t,column:c};n.reportError(o)}catch(n){}return!1},window.addEventListener("error",(function(o){try{const r={url:location.href,type:2,error:o.message,file:o.filename,line:o.lineno,column:o.colno},e=o.target||o.srcElement;e&&e instanceof HTMLElement&&n.reportError(r)}catch(n){}}),!0)}(n)}const e="1.0.1";export{r as init,o as sendBeacon,n as sendImage,e as version}; | ||
//# sourceMappingURL=web-error.esm.min.js.map |
/** | ||
* web-error.js v1.0.0 | ||
* web-error.js v1.0.1 | ||
* (c) 2021-2022 shushu2013 | ||
@@ -55,3 +55,8 @@ * Released under the MIT License. | ||
}; | ||
config.reportError(msgObj); | ||
// 只上报资源类型的错误 | ||
var target = event.target || event.srcElement; | ||
var isHTMLElement = target && target instanceof HTMLElement; | ||
if (isHTMLElement) { | ||
config.reportError(msgObj); | ||
} | ||
} | ||
@@ -63,3 +68,6 @@ catch (err) { | ||
// event.preventDefault() | ||
}, true); | ||
}, | ||
// 当一项资源(如<img>或<script>)加载失败,该 error 不会冒泡到 window,可在捕获阶段捕获 | ||
// true 代表在捕获阶段调用,false 代表在冒泡阶段 | ||
true); | ||
// 当 Promise 被 reject 且没有 reject 处理器的时候 | ||
@@ -101,3 +109,3 @@ // 会触发 unhandledrejection 事件 | ||
*/ | ||
var version = "1.0.0"; | ||
var version = "1.0.1"; | ||
@@ -104,0 +112,0 @@ exports.init = init; |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).Url={})}(this,(function(e){"use strict";e.init=function(e){!function(e){var n=window.onerror;window.onerror=function(o,r,t,i,f){n&&n(o,r,t,i,f);try{var l={url:location.href,type:1,error:o.toString(),file:r,line:t,column:i};e.reportError(l)}catch(e){}return!1},window.addEventListener("error",(function(n){try{var o={url:location.href,type:2,error:n.message,file:n.filename,line:n.lineno,column:n.colno};e.reportError(o)}catch(e){}}),!0)}(e)},e.sendBeacon=function(e,n){navigator.sendBeacon(e,n)},e.sendImage=function(e,n){var o=new Image;o.onload=o.onerror=function(){o=o.onload=o.onerror=null},o.src=e+"?"+n},e.version="1.0.0",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).Url={})}(this,(function(e){"use strict";e.init=function(e){!function(e){var n=window.onerror;window.onerror=function(o,r,t,i,l){n&&n(o,r,t,i,l);try{var c={url:location.href,type:1,error:o.toString(),file:r,line:t,column:i};e.reportError(c)}catch(e){}return!1},window.addEventListener("error",(function(n){try{var o={url:location.href,type:2,error:n.message,file:n.filename,line:n.lineno,column:n.colno},r=n.target||n.srcElement;r&&r instanceof HTMLElement&&e.reportError(o)}catch(e){}}),!0)}(e)},e.sendBeacon=function(e,n){navigator.sendBeacon(e,n)},e.sendImage=function(e,n){var o=new Image;o.onload=o.onerror=function(){o=o.onload=o.onerror=null},o.src=e+"?"+n},e.version="1.0.1",Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=web-error.min.js.map |
{ | ||
"name": "@yorkjs/web-error", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "process web-error and report tool", | ||
@@ -5,0 +5,0 @@ "main": "dist/web-error.js", |
@@ -8,2 +8,2 @@ import { Config } from './type'; | ||
*/ | ||
export declare const version = "1.0.0"; | ||
export declare const version = "1.0.1"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12811
242