You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (Commented) (JIRA)" <ji...@apache.org> on 2012/01/27 14:55:37 UTC

[jira] [Commented] (WICKET-4362) AJAX reloading of stylesheets does not work with HtmlUnit

    [ https://issues.apache.org/jira/browse/WICKET-4362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13194712#comment-13194712 ] 

Martin Grigorov commented on WICKET-4362:
-----------------------------------------

A workaround: monkey patch that specific method when the user agent is "HtmlUnit".
I.e. add an additional .js in your app (in test mode) which overrides the prototype of Wicket.Head and replaces this method with one that is htmlunit friendly.
                
> AJAX reloading of stylesheets does not work with HtmlUnit
> ---------------------------------------------------------
>
>                 Key: WICKET-4362
>                 URL: https://issues.apache.org/jira/browse/WICKET-4362
>             Project: Wicket
>          Issue Type: Bug
>            Reporter: Andreas Kappler
>            Priority: Minor
>              Labels: ajax, htmlunit, javascript
>
> There is an issue with dynamically loading stylesheets when using HtmlUnit.
> In wicket-ajax.js:1624 the following code is used to detect when the stylesheet has loaded:
>  // cross browser way to check when the css is loaded
>  // taked 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() {
>      if (!notifyCalled) {
>          notifyCalled = true;
>          notify();
>      }
>  }
>  img.src = css.href;
>  if (img.complete) {
>      if (!notifyCalled) {
>          notifyCalled = true;
>          notify();
>      }
>  }
> The trick with the img tag does not work in HtmlUnit and notify will never be called which results in the AJAX response not being parsed successfully.
> This may well be a HtmlUnit problem but I put this on this tracker in case somebody has another solution for the problem that could make it in the next wicket maintenance release. HtmlUnit is somewhat slower with its release plan.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira