Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#45472 closed defect (bug) (fixed)

Incorrect wp_get_script_polyfill() call in script loader

Reported by: swissspidy's profile swissspidy Owned by: desrosj's profile desrosj
Milestone: 5.0.2 Priority: normal
Severity: minor Version: 5.0
Component: Script Loader Keywords: has-patch fixed-5.0
Focuses: Cc:

Description

Script polyfills are currently loaded like this:

did_action( 'init' ) && $scripts->add_inline_script(
        'wp-polyfill',
        wp_get_script_polyfill(
                $scripts,
                array(
                        '\'fetch\' in window' => 'wp-polyfill-fetch',
                        'document.contains'   => 'wp-polyfill-node-contains',
                        'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
                        'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
                ),
                'after'
        )
);

This incorrectly passes 'after' as the third parameter to wp_get_script_polyfill(), which only accepts two parameters. It's clear that this argument is meant for add_inline_script() instead.

However, since after is the default argument for add_inline_script() anyway, it can be safely omitted

Attachments (1)

45472.diff (538 bytes) - added by swissspidy 6 years ago.

Download all attachments as: .zip

Change History (7)

@swissspidy
6 years ago

#1 @pento
6 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#2 @swissspidy
6 years ago

  • Keywords commit added

#3 @pento
6 years ago

In 44208:

Scripts: Remove an incorrect parameter sent to wp_get_script_polyfill().

wp_get_script_polyfill() only accepts two parameters, but this call was passing a third.

Props swissspidy.
See #45472.

#4 @pento
6 years ago

  • Keywords fixed-5.0 added

#5 @desrosj
6 years ago

  • Keywords commit removed

#6 @desrosj
6 years ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

In 44308:

Script Loader: Misplaced parenthesis when wp-tinymce-lists is added.

A closing parenthesis was misplaced in the $scripts->add( 'wp-tinymce-lists' ) call, causing the dependencies and version to be incorrectly passed to includes_url() instead.

Also, Remove an incorrect parameter sent to wp_get_script_polyfill(). wp_get_script_polyfill() only accepts two parameters, but this call was passing a third.

Props volodymyrkolesnykov, swissspidy.

Merges [44208] and [44211] into trunk.

Fixes: #45506, #45472.

Note: See TracTickets for help on using tickets.