Skip to content

replace all .srcElement with .target#10

Open
andiHaven wants to merge 3 commits intoselsamman:masterfrom
andiHaven:replace_srcElement_with_target
Open

replace all .srcElement with .target#10
andiHaven wants to merge 3 commits intoselsamman:masterfrom
andiHaven:replace_srcElement_with_target

Conversation

@andiHaven
Copy link
Copy Markdown
Contributor

.srcElement is non-standard and is not supported in Firefox, so this causes some bugs in Firefox. .target is supported everywhere (IE >= 9 and all other browsers).

@selsamman
Copy link
Copy Markdown
Owner

At present BINDSter has backwards compatibility to XP-only browsers (e.g. IE 8). In all the cases you patched we were testing to see if target existed. The only exception was the return value which was to correct an IE only problem. Can you let me know the nature of the bug you found with Firefox.

@andiHaven
Copy link
Copy Markdown
Contributor Author

I didn't realize Bindster supported IE8; I asked around and was told that it didn't, so that's why I just removed srcElement. We can certainly add more conditions to test target vs srcElement, rather than my just getting rid of srcElement all together. But target should be the default since it's part of the standard, and srcElement should be used only when target fails.
The actual problem I found which required that fix was that checkboxes on the HIT admin site using b:onclick weren't getting checked in Firefox when I clicked on them. In other browsers, b:onclick returned true for a checkbox, but because of Firefox not supporting srcElement, the return value of b:onclick incorrectly ended up as false.
The main problem was in these do_return lines where it went straight to srcElement without testing if target existed:
var do_return ="return (ev && ev.srcElement && ev.srcElement.tagName && ev.srcElement.tagName == 'INPUT' ? true : " + do_return + ");";

@selsamman
Copy link
Copy Markdown
Owner

selsamman commented Dec 20, 2016 via email

@andiHaven
Copy link
Copy Markdown
Contributor Author

bindster.com says "Compatible back to IE6"... is that true? and if so, you intend to keep it that way?

In the example above, I think it's expected that val5 would show the updated value of the checkbox.
The checkbox checked property is first updated, then the onclick event handler is run. (and then if the onclick event handler returns false, the checkbox is reverted to its original state.)
It's a strange sequence of events, but I think people just have to be aware of that when creating event handlers.

For the original issue, it has nothing to do with the version of Firefox. Firefox just doesn't support srcElement, and those do_return statements rely on srcElement without testing for target.

@andiHaven
Copy link
Copy Markdown
Contributor Author

I just updated the PR to keep the tests for srcElement, but this should still fix the Firefox issue.

@selsamman
Copy link
Copy Markdown
Owner

selsamman commented Dec 21, 2016 via email

@andiHaven
Copy link
Copy Markdown
Contributor Author

andiHaven commented Dec 21, 2016

Hi Sam,
The UW team was using checkboxes in perhaps a non-standard way for Bindster; the checkboxes were not bound to a value, but the onclick handler was used to run a function when the checkboxes were clicked, and the checkboxes were expected to toggle as normal.
Try replicating the issue with code like this:
<input type="checkbox" b:onclick="node" /> (or other similar onclick event that does nothing, just for the purpose of having an onclick handler there.)
Andi

@selsamman
Copy link
Copy Markdown
Owner

selsamman commented Dec 24, 2016 via email

@andiHaven
Copy link
Copy Markdown
Contributor Author

I'm confused on what you mean here. I think my updated changes will benefit Firefox without having a negative effect on IE, because I just added a check for ev.target in addition to the check for ev.srcElement, so the logic for IE should not have changed. Let's talk in person next week if the test case or anything isn't clear.

@andiHaven
Copy link
Copy Markdown
Contributor Author

Just added the test case in /test/multivalue.html. Please take a look at that checkbox in both Firefox and Chrome, before and after including the other changes in this PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants