WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/09/2021 01:09:08 AM (4 months ago)
Author:
noisysocks
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.

See #53437.
Props zieladam, spacedmonkey, TimothyBlynJacobs, andraganescu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r51380 r51387  
    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.