#42553 closed defect (bug) (fixed)
IE11: content loss when editing a post (Object doesn't support property or method 'matches')
Reported by: | afercia | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9 | Priority: | high |
Severity: | critical | Version: | 4.9 |
Component: | Editor | Keywords: | has-screenshots has-patch dev-reviewed commit |
Focuses: | Cc: |
Description
Reproduced on 3 different Windows machines thanks to @SergeyBiryukov.
Probably related to the changes to keep the selection when switching editor mode, see [41630] and following changes. See also #42530 and #42531.
To reproduce:
Create a new post with some simple content, for example:
Welcome to WordPress. This is your first post. Edit or delete it, then start writing! Second paragraph. Third paragraph.
- publish the post and navigate away from the page
- open again the post, make sure the Editor is in "Visual mode" on first load
- switch to "Text mode"
- switch back to "Visual mode"
- the first paragraph in the content gets removed
Keep switching editor modes: I've observed also the second and third paragraphs get removed or, depending on if there's a selection or the caret position, parts of them but couldn't reproduce consistently.
I'm not sure it's really related, but the error Object doesn't support property or method 'matches'
happens when switching Editor mode and comes from TinyMCE, not sure what code in the keep selection feature is using TinyMCE methods.
Also, from @SergeyBiryukov:
I can also reproduce the Object doesn't support property or method 'matches'
error even without creating a post:
- Open "Add New Post" screen.
- Make sure Visual tab is displayed.
- Click anywhere inside the editor content area and you'll get the error.
Attachments (9)
Change History (31)
#3
@
7 years ago
Double clicking a word to select it doesn't work.
Of course, also triple clicking to select a paragraphs doesn't work.
#4
@
7 years ago
The Object doesn't support property or method 'matches'
error also appears when using return to add a newline, needs a double-tap or to be part of a sequence of keystrokes to not be blocked.
I'm also seeing an empty line at the end of the visual editor get moved to the top of the editor when switching back and forth between text and visual mode, although it isn't consistent so I suspect a race condition somewhere for this one.
Can consistently reproduce the losing of paragraphs by quickly swapping between text and visual mode.
This ticket was mentioned in Slack in #core-committers by westonruter. View the logs.
7 years ago
#6
@
7 years ago
I tried manually fixing the TinyMCE issue via the following (which I don't understand why selectorType
is being set to STANDARD
in the first place):
-
src/wp-includes/js/tinymce/tinymce.js
define( 16416 16416 16417 16417 // As of Chrome 34 / Safari 7.1 / FireFox 34, everyone except IE has the unprefixed function. 16418 16418 // Still check for the others, but do it last. 16419 else if (selectorType === STANDARD ) return elem.matches(selector);16420 else if (selectorType === MSSTANDARD ) return elem.msMatchesSelector(selector);16419 else if (selectorType === STANDARD && elem.matches) return elem.matches(selector); 16420 else if (selectorType === MSSTANDARD || elem.msMatchesSelector) return elem.msMatchesSelector(selector); 16421 16421 else if (selectorType === WEBKITSTANDARD) return elem.webkitMatchesSelector(selector); 16422 16422 else if (selectorType === FIREFOXSTANDARD) return elem.mozMatchesSelector(selector); 16423 16423 else throw new Error('Browser lacks native selectors'); // unfortunately we can't throw this on startup :(
However, then a different IndexSizeError
then occurs.
#7
follow-up:
↓ 9
@
7 years ago
- Keywords has-patch added; needs-patch removed
What what we could do is just forcibly prevent the wp_keep_scroll_position
behavior in IE.
@Clorith please try 42553.poc.diff. It fixes the errors in IE11 for me.
#8
@
7 years ago
Sorted out the errors on my end as well, also unable to reproduce the loss of paragraphs and other things mentioned in the ticket now.
#9
in reply to:
↑ 7
@
7 years ago
Replying to westonruter:
please try 42553.poc.diff. It fixes the errors in IE11 for me.
Seems to work as expected for me as well.
Given that IE11 is the only supported version though, maybe not enabling wp_keep_scroll_position
in the first place would be cleaner? See 42553.alt.diff.
#10
@
7 years ago
There's a similar $is_IE
check earlier in the file for editor_expand
feature: tags/4.8.3/src/wp-admin/edit-form-advanced.php?marks=33#L23.
#11
@
7 years ago
- Keywords needs-testing added
- Owner set to westonruter
- Status changed from new to accepted
We found out that the TinyMCE bug is actually because of a clash with MediaElement.js. The is
selector lookup function in TinyMCE is using a selectorType
function that gets computed at init in the top window where MediaElement.js also loaded. MediaElement.js implements a matches
polyfill on Element.prototype
, so when selectorType
is computed TinyMCE thinks that it is natively available. Later, however, when TinyMCE calls its is
function it does so in the context of the TinyMCE iframe window, not the parent window where MediaElement.js has applied its polyfill. In short, TinyMCE really does need to do on the fly feature detection for the matches
function. This is implemented in 42553.3.diff. Currently getting the TinyMCE team to review.
This ticket was mentioned in Slack in #core by westonruter. View the logs.
7 years ago
#13
@
7 years ago
- Keywords dev-feedback added; needs-testing removed
I suppose we should bump the $tinymce_version
as well?
#14
@
7 years ago
We will fix this upstream as well the patch looks fine. We where caching the feature detection.
#15
@
7 years ago
Bumping $tinymce_version
similarly to what was done in https://github.com/WordPress/wordpress-develop/commit/43f2ae72928506ed30c12f9d8722750608a3316f#diff-cf3602dbbc7654a7f09aac1e6ec7456e
#17
@
7 years ago
- Keywords dev-reviewed added; dev-feedback removed
Tested 42553.4.diff, looks good to me.
#20
@
7 years ago
@spocke @afraithe I opened a PR to ephox/sugar with this fix as well: https://github.com/ephox/sugar/pull/1
Additional issues with 4.9 in IE11:
Both cause the same
Object doesn't support property or method 'matches'
error.4.8.3 appears to work as expected.