This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch WICKET-6748-css-onload in repository https://gitbox.apache.org/repos/asf/wicket.git
commit b1ed2bfd1cb1da23c47c082d497abfef3c36af13 Author: Maxim Solodovnik <solomax...@gmail.com> AuthorDate: Mon Feb 10 16:47:30 2020 +0700 [WICKET-6748] CSS onload/onerror is rewritten --- .../apache/wicket/ajax/res/js/wicket-ajax-jquery.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js index 3647df2..86cf3e8 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js @@ -1821,28 +1821,17 @@ $css.attr(this.name, this.value); }); - // add element to head - Wicket.Head.addElement(css); - - // cross browser way to check when the css is loaded - // taken from http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/ - // this makes a second GET request to the css but it gets it either from the cache or - // downloads just the first several bytes and realizes that the MIME is wrong and ignores the rest - var img = document.createElement('img'); var notifyCalled = false; - img.onerror = function () { + function doNotify() { if (!notifyCalled) { notifyCalled = true; notify(); } - }; - img.src = css.href; - if (img.complete) { - if (!notifyCalled) { - notifyCalled = true; - notify(); - } } + css.onerror = doNotify; + css.onload = doNotify; + // add element to head + Wicket.Head.addElement(css); return FunctionsExecuter.ASYNC; });