-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix two IE8 JavaScript bugs #120
Conversation
Thanks for this @zarino. Seems good overall but I have a few questions/comments
Is this because of the use of While you're in IE8 land, could you see if the real solution to the attribute problem is to just use If that's the case, there are a few other places that do the same attribute modification so wouldn't this problem still exist there? I was wondering why there was only one place where this was needed. Not sure why the build is crashing but hopefully that's a fluke. |
IE8 does not allow you to change the `type` property of a button after it has been created (eg: by createElement). But it *does* seem to allow you to change the `type` *attribute*, which is good enough for our needs (preventing the parent form from being submitted when the Close button on a Taggle tag is clicked).
The error was (To get the code into a state where you can try this out, you need to fix the As far as I can tell, IE8 has no concept of HTMLElement:
Genius! Everything I read online suggested there was simply no way of changing the I’ve updated my commit to use
This puzzled me at the time too. I can confirm that, in IE8:
As far as I can tell, we can access the
Looks like Travis hit a Cloudflare rate limiting error from |
Gotta love IE 👍 Thanks for these fixes @zarino |
No problem! Thanks for sharing the library :-) In case you’re interested, here’s the project we’re using it in: mysociety/foi-for-councils#112 |
Your README includes a "Support for old IE" section, so I’m assuming IE8 support is something you want to maintain.
I found two IE8 bugs in taggle.js while attempting to reuse it in a mySociety project.
HTMLElement
existed – whereas IE8 has noHTMLElement
, so you have to useElement
in IE8 insteadtype
property of the "Close" button after the element had been created – whereas IE8 doesn’t let you modify special properties of<input>
and<button>
elements (liketype
andname
) after they have been createdThis PR includes fixes for both bugs.
There’s unfortunately another IE8 bug I spotted—this time with the example CSS—but sadly didn’t have time to fix. For posterity:
/example/css
, the.taggle_input
is always invisible. You can focus the input (without getting any visual feedback) and even type into it (without seeing any of the text), and when you hit,
orEnter
, the tag gets created as you’d expect. I think the issue is that you’re setting.taggle_input
towidth: 100%
but its parentli
has no explicit width, so IE8 assumes a width of0
. Setting amin-width
of10%
or whatever on.taggle_input
fixes the invisibility problem, but reveals a black border around the element, that I can’t work out how to remove.Since the example styles are only included as an indication of how you could style the component—and most people will be writing their own styles—I guess maybe this invisibile input bug isn’t a deal-breaker. But I figured I should mention it.