Minor change to allow some webform shim functionality even if polyfiller is loaded and/or initialized post DOMReady #79

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
@ghost

ghost commented Dec 9, 2011

Change was made so that polyfiller could be late loaded and webform
shims would still work. If DOMReady has occurred functions that are
waiting for another DOMReady event (which won't happen) will now fire
immediately. New demo page tested in latest builds of Firefox, Safari
and Chrome as well as IE7-9.

Post DOMReady init of polyfiller now supported for some webform shims.
Change was made so that polyfiller could be late loaded and webform
shims would still work. If DOMReady has occurred functions that are
waiting for another DOMReady event (which won't happen) will now fire
immediately. New demo page tested in latest builds of Firefox, Safari
and Chrome as well as IE7-9.
Owner

aFarkas commented Dec 9, 2011

Hi,

I'm not 100% sure, wether I understand your code/purpose right. If I try your demo page without the changes, everything is fine (short test in IE9/FF8). My hole testsuite is testing webshims by calling polyfill after the load event.

I do generate Special 'Ready' events, which are immediately fired, if you add a new event-listener. This special event handler is created by overriting the normal jQuery ready method.

In case your using polyfill after DOMReady I always suggest to set waitReady option to false, because it doesn't work as expected. -> Webshims doesn't delay the domready method anymore until all features are loaded and implemented. Could you please explain in more detail, what the problem is. If your code doesn't work right (polyfilling after ready-event), you found a bug, because it should already work, but I have difficulties to reproduce this.

cheers and thanks for working on the code :-)
alex

Removing webforms_postready demo.
Not an accurate example of the issue.
@ghost

ghost commented Dec 10, 2011

Sorry about the confusion. The demo file I submitted wasn't the correct scenario (I had been testing something else and submitted that by mistake).

The change I made in polyfiller.js fixes an issue I was having when attempting to dynamically load webshims. Here's what I went through:

To get the webforms portion of webshim to work I had to follow your instructions on Stack Overflow pertaining to yepnope (http://stackoverflow.com/questions/5433126/html5-modernizr-yepnope-webforms2-issue) to get the library to load without any errors. Of course the "You should call $.webshims.polyfill before DOM-Ready" message still appears.

Then the validation polyfills wouldn't appear because .validity-alert-wrapper was still waiting for a DOMReady event, before appending to the body. (line 347 of shim/form-core.js)

The change I made insures that callbacks in a webshims.ready('DOM') call fire immediately if DOMReady has already occurred. I could have just added my fix just to form-core.js but I figured this would resolve the issue if other shims functioned similarly.

I'm sure you're more intimately aware of any ramifications my change could have so if there's a more elegant solution you can suggest I'm eager to hear it.

Owner

aFarkas commented Dec 11, 2011

Ah, I think I understand this now and this is a bug. Instead of modifiying polyfiller.js. Can you try to simply add the following code after jQuery and polyfiller is loaded:

jQuery(function($){
    $.webshims.isReady('DOM', true);
});

Your code fixes the event API, but doesn't fix the isReady API (which isn't currently used but might be used in the future). If this fixes your issue, I will fix it with next release. I hope, I can do this soon, but I do need to find a better solution for issue #78.

@ghost

ghost commented Dec 11, 2011

That seems to do the trick. Thank you so much for the quick response.

@ghost ghost closed this Dec 11, 2011

aFarkas added a commit that referenced this pull request Dec 11, 2011

Owner

aFarkas commented Dec 18, 2011

@dcmoore-gd

Is this info for me? I don' t really understand. How can I help? Are you using something like custom styleable select elements?

Contributor

dcmoore-gd commented Dec 18, 2011

@aFarkas No, I'm sorry about that. Outlook address completion had somehow decided that the GitHub email for this thread was the same as the corporate email address of a colleague. Sorry again!

aFarkas added a commit that referenced this pull request Jan 12, 2012

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment