WordPress.org

Make WordPress Core

Changeset 51392


Ignore:
Timestamp:
07/09/2021 05:53:24 PM (4 months ago)
Author:
desrosj
Message:

Editor: Merge conflicting wp.editor objects into single, non-conflicting object

The wp-editor script (@wordpress/editor npm package) is exposed as
window.wp.editor in WP Admin. This causes problems, though, as many older
scripts expect to see the older editor script available at window.wp.editor.

The solution is to export all the members of the older window.wp.editor module
in the newer module to maintain backwards compatibility.

Props zieladam, spacedmonkey, TimothyBlynJacobs, andraganescu, noisysocks.
Merges [51387] to the 5.8 branch.
See #53437.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/src/wp-includes/script-loader.php

    r51384 r51392  
    380380        'editor',
    381381        'window.wp.oldEditor = window.wp.editor;',
     382        'after'
     383    );
     384
     385    // wp-editor module is exposed as window.wp.editor
     386    // Problem: there is quite some code expecting window.wp.oldEditor object available under window.wp.editor
     387    // Solution: fuse the two objects together to maintain backward compatibility
     388    // For more context, see https://github.com/WordPress/gutenberg/issues/33203
     389    $scripts->add_inline_script(
     390        'wp-editor',
     391        'Object.assign( window.wp.editor, window.wp.oldEditor );',
    382392        'after'
    383393    );
Note: See TracChangeset for help on using the changeset viewer.