Skip to content

Conversation

@mgol
Copy link
Member

@mgol mgol commented Apr 16, 2019

Summary

The test for Shadow DOM v1 support has been changed to rely on the presence of
documentElement.getRootNode as iOS 10.0-10.2 supports attachShadow but
doesn't support getRootNode.

No new test is necessary - iOS 10.0 fails lots of our test suite because of
this bug.

Fixes gh-4356

Checklist

@mgol
Copy link
Member Author

mgol commented Apr 16, 2019

We won't support iOS 10.0-10.2 in jQuery 4 so this doesn't need to land on master but I'll cherry-pick the fix there anyway as it decreases size. I'll incorporate that into #4347.

@mgol mgol force-pushed the ios10-isattached branch from 82ec0b0 to ad09efa Compare April 17, 2019 18:16
@diegocr
Copy link

diegocr commented Apr 18, 2019

fwiw, please note this is not only limited to iOS 10.0-10.2, the issue also happens under other platforms.

Here are some desktop/mobile browsers we've detected:

  • Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; Redmi Note 5 Build/OPM1.171019.011) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.146 Mobile Safari/537.36 XiaoMi/MiuiBrowser/9.5.6
  • Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.21 Safari/537.36 MMS/1.0.2531.0
  • Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36
  • Mozilla/5.0 (Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 OPR/40.0.2207.0 OMI/4.9.0.237.DOM3.223 Model/Vestel-MB211 VSTVB MB200 HbbTV/1.2.1 (; TOSHIBA; MB211; 1.31.2.3; _TV_NT72563_2017;) SmartTvA/3.0.0
  • Mozilla/5.0 (Linux; Andr0id 7.0; BRAVIA 4K 2015 Build/NRD91N.S28) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 OPR/40.0.2207.0 OMI/4.9.0.59.E9103576.154

I.e. basically anything using Chromium 53.x as well it seems ...

@whitelynx
Copy link

I just ran into this same issue when upgrading jQuery in an Electron-based app. (electron v1.4.13)

// Support: iOS 10.0-10.2 only
// Early iOS 10 versions support `attachShadow` but not `getRootNode`,
// leading to errors. We need to check for `getRootNode`.
if ( documentElement.getRootNode ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to MDN (and my previous post), this is not only limited to iOS:

image

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't officially support Chrome 53 (see https://jquery.com/browser-support/) so I didn't check that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check what's up with Firefox, thanks for the pointer!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to be of help, and thanks for enlightening me about the officially supported versions, missed that sorry.

test/unit/css.js Outdated
} );

QUnit[ document.body.attachShadow ? "test" : "skip" ]( "show/hide shadow child nodes", function( assert ) {
QUnit[ document.body.getRootNode ? "test" : "skip" ]( "show/hide shadow child nodes", function( assert ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the browser compatibility table from MDN i posted above, this test will fail under Firefox 53-63, these versions does support getRootNode but not attachShadow, so since this test rely on the later this change should not be needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking for attachShadow here would run the test in iOS 10.0 where it'd fail. We either need to check both or blacklist specific browsers by user agent (as it's just tests).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer, though! I didn't notice these tests would fail in Firefox 60 ESR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, got it now after inspecting further... getNodeRoot is not used here, but will get invoked within the library code when swapping the display style 👍

So... yeah, this may turns tricky for Firefox.

@mgol mgol force-pushed the ios10-isattached branch 2 times, most recently from 4f115eb to db75f80 Compare April 24, 2019 19:59
@mgol
Copy link
Member Author

mgol commented Apr 24, 2019

PR updated, thank you @diegocr for noticing test problems related to Firefox 60 ESR!

I think the fact that in Firefox 60 we now use getRootNode in isAttached.js is fine since it's supported; it's just that we can't create our own shadow nodes as attachShadow is not supported in that browser so we can't effectively test it. Tests updated, Firefox 60 should now pass it all.

Copy link

@diegocr diegocr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, someone else more familiar with the codebase may want to double check though :-)

The test for Shadow DOM v1 support has been changed to rely on the presence of
`documentElement.getRootNode` as iOS 10.0-10.2 supports `attachShadow` but
doesn't support `getRootNode`.

No new test is necessary - iOS 10.0 fails lots of our test suite because of
this bug.

Fixes jquerygh-4356
@mgol mgol force-pushed the ios10-isattached branch from db75f80 to 90da3b3 Compare April 29, 2019 17:32
@mgol mgol removed the Needs review label Apr 29, 2019
@mgol mgol merged commit 7dddb19 into jquery:3.4-stable Apr 29, 2019
@mgol mgol deleted the ios10-isattached branch April 29, 2019 17:54
@lock lock bot locked as resolved and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

5 participants