Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Fix TypeError when event.target is HTMLDocument #316

Merged
merged 3 commits into from
Jul 31, 2017

Conversation

torlye
Copy link
Contributor

@torlye torlye commented Apr 5, 2017

If you put a ContextualMenu and a DatePicker on the same page; and click inside the DatePicker; you get an unhandled TypeError.

ContextualMenu _onDocumentClick asserts event.target as HTMLElement. However, when you click in the DatePicker's textfield; the DatePicker will fire an event with the document object as a target. (Jquery.DatePicker.ts line 112)

Since the document object is an HTMLDocument, not an HTMLElement, classList ends up as undefined. Hence you get the TypeError when trying to access classList.contains.

Attachment: A minimal HTML page to reproduce the problem. (Rename the file extension)

contextualmenu-datecontrol-bug.html.txt

@msftclas
Copy link

msftclas commented Apr 5, 2017

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

@Jahnp
Copy link
Collaborator

Jahnp commented Jul 31, 2017

Hey @torlye, so sorry for the delay here, didn't see the notification for this PR. The changes look great--thank you! I'll go ahead and merge this in.

@Jahnp Jahnp merged commit 34192bf into OfficeDev:master Jul 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants