Open theprojectsomething opened 8 years ago
@theprojectsomething Thanks for this!
@viljamis I'm confused as to what we're actually trying to test with feature.contextMenu
.
@theprojectsomething is right. This test fails almost entirely across the board, unless you're in a Gecko-based browser, like Firefox, but from what I can tell it's not due to the HTMLMenuItemElement
portion of the test. Testing reveals that Chrome and Edge also return false on the ('contextMenu' in document.documentElement)
portion of the test as well.
If we're trying to test for the support of the contextmenu
event, I think that's a different test entirely. We could employ something like this for event-based detection.
I was a little surprised to see that Modernizr also constructs its test this way.
I'm soliciting feedback from the Modernizr community on this one.
The ContextMenu test requires both
contextmenu
andHTMLMenuItemElement
to be present. As the latter is currently unsupported in everything but Gecko this test returns false across all other major browsers. More importantlycontextmenu
alone is enough to override a context menu (or 'right-click' as is mentioned on the test page).Is
HTMLMenuItemElement
necessary, and if so should the test be split in two?The following code suppresses a context menu on all modern browsers:
document.addEventListener( "contextmenu", function(e) { e.preventDefault(); });