Commit Graph

52 Commits

Author SHA1 Message Date
Andrew Duthie
2c795289c8 Script Loader: Add polyfill for window.URL, window.DOMRect.
Pending block editor revisions for WordPress 5.4 will make use of `window.URL` and `window.DOMRect`. These are not available in Internet Explorer (or pre-Chromium Edge for `DOMRect`) and must be polyfilled to avoid script errors.

The changes make use of the existing polyfill pattern, and existing `polyfill-library` dependency. The dependency is bumped to the latest version, since the previous version did not include the `DOMRect` polyfill.

Props jorgefilipecosta.
Fixes #49360.


git-svn-id: https://develop.svn.wordpress.org/trunk@47238 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-10 15:15:07 +00:00
Sergey Biryukov
cfc3b57488 Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-29 00:43:23 +00:00
Sergey Biryukov
b0419afba6 Build/Test Tools: Ignore EOL differences in tests using multiline string assertions.
Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result.

Fixes #31432. See #42594, #47411.

git-svn-id: https://develop.svn.wordpress.org/trunk@46612 602fd350-edb4-49c9-b593-d223f7449a82
2019-10-29 14:26:41 +00:00
Sergey Biryukov
e5bee4ef68 Docs: Format multi-line comment in [46180] per the documentation standards.
See #45066.

git-svn-id: https://develop.svn.wordpress.org/trunk@46181 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-19 11:39:01 +00:00
Sergey Biryukov
a87122688b Tests: Update unit tests to account for the removal of old wp-a11y from the loaded scripts in [46179].
Props sstoqnov.
See #45066, #48071.

git-svn-id: https://develop.svn.wordpress.org/trunk@46180 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-19 11:14:38 +00:00
Jake Spurlock
b8533a19b8 Accesibility: Replace wp-a11y.js with @wordpress/a11y package
Continuation of [46167]. This fixes the tests that ended up broken following the previous commit.

We've extracted wp-includes/wp-a11y.js to a reusable package wordpress/a11y which is published on NPM. Let's make sure this package is also 
used in WordPress core. Once all the JavaScript is built using webpack, we can also import this package wherever it is used and configure 
webpack to load is an external.

Props, garrett-eclipse

Fixes #45066



git-svn-id: https://develop.svn.wordpress.org/trunk@46169 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 22:29:53 +00:00
Jake Spurlock
8029e23ffe Accessibility: Replace wp-a11y.js with @wordpress/a11y package
We've extracted wp-includes/wp-a11y.js to a reusable package wordpress/a11y which is published on NPM. Let's make sure this package is also used in WordPress core. Once all the JavaScript is built using webpack, we can also import this package wherever it is used and configure webpack to load is an external.

Props omarreiss, herregroen, desrosj, ocean90, afercia, sstoqnov



git-svn-id: https://develop.svn.wordpress.org/trunk@46167 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 17:40:35 +00:00
Sergey Biryukov
5fdf48c0ec Script Loader: Introduce HTML5 support for scripts and styles.
When a theme declares HTML5 support for script and styles via `add_theme_support( 'html5', array( 'script', 'style' ) )`, the `type="text/javascript"` and `type="text/css"` attributes are omitted.

These attributes are unnecessary in HTML5 and cause warnings in the W3C Markup Validation Service.

Props sasiddiqui, swissspidy, knutsp, SergeyBiryukov.
See #42804.

git-svn-id: https://develop.svn.wordpress.org/trunk@46164 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-18 14:49:30 +00:00
Jake Spurlock
c957e2573e Update wp.a11y.speak() to sanitize HTML before display.
Props iandunn, adamsilverstein, sstoqnov, peterwilsoncc


git-svn-id: https://develop.svn.wordpress.org/trunk@45979 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-04 17:11:22 +00:00
Andrew Ozz
3337e709ee Fix unit tests after [45456]. The query string is a bit different but the results are the same.
See #45346.

git-svn-id: https://develop.svn.wordpress.org/trunk@45458 602fd350-edb4-49c9-b593-d223f7449a82
2019-05-28 04:18:53 +00:00
Peter Wilson
41e264fe55 Build: Fix formatting issues introduced in [44740].
See #46218.



git-svn-id: https://develop.svn.wordpress.org/trunk@44744 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-14 00:41:15 +00:00
Peter Wilson
3ec3100195 Build: Remove source map from jquery.form.min.js.
Minimize jquery.form.js as part of build process to remove the source map reference. 

Modify source map tests to include all JavaScript files rather than testing Backbone and jQuery only.

Props pento.
Fixes #46218.



git-svn-id: https://develop.svn.wordpress.org/trunk@44740 602fd350-edb4-49c9-b593-d223f7449a82
2019-02-14 00:06:39 +00:00
Gary Pendergast
bcba20dd2b Docs: Fix the last handful of incorrect @since 5.0.0 docblock tags.
Props peterwilsoncc.
Fixes #45543.



git-svn-id: https://develop.svn.wordpress.org/trunk@44635 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 06:45:58 +00:00
Dominik Schilling (ocean90)
690b0cbf83 I18N/Script Loader: Support text domains other than "messages".
The inline JavaScript added by `WP_Scripts::print_translations()` should check whether `locale_data.$text_domain` exists and fall back to `locale_data.messages` otherwise.

Props swissspidy.
See #45441.

git-svn-id: https://develop.svn.wordpress.org/trunk@44403 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-06 16:22:46 +00:00
Sergey Biryukov
a10598acd0 I18N: Set translations for all WordPress packages scripts.
Calls `wp_set_script_translations` for all packages scripts that have translations. Also correctly sets the domain on the translations.

Props omarreiss, pento, ocean90.
Merges [43878] to trunk.
Fixes #45161.

git-svn-id: https://develop.svn.wordpress.org/trunk@44239 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-16 22:23:34 +00:00
Gary Pendergast
8d897837aa I18N: Add JavaScript translation support.
Adds the `wp_set_script_translations()` function which registers translations for a JavaScript file. This function takes a handle, domain and optionally a path and ensures JavaScript translation files are loaded if they exist.

Merges [43825,43828,43859,43898] from the 5.0 branch to trunk.

Props herregroen, atimmer, omarreiss, nerrad, swissspidy, ocean90, georgestephanis.
Fixes #45103, #45256.



git-svn-id: https://develop.svn.wordpress.org/trunk@44169 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 05:51:31 +00:00
Jonathan Desrosiers
89d76b9884 PHP7.3 compatibility: Fix compact throwing notices.
In PHP 7.3, the `compact()` function has been changed to issue an `E_NOTICE` level error if a passed string refers to an unset variable. In previous versions of PHP, this notice was silently skipped. The full RFC can be viewed here: https://wiki.php.net/rfc/compact.

Props jorbin, desrosj.

Merges [43819] and [43832] to trunk.

Fixes #44416.

git-svn-id: https://develop.svn.wordpress.org/trunk@44166 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 05:12:12 +00:00
Jonathan Desrosiers
76525a75b7 Styles: Add helper functions for loading block styles.
Blocks are able to register styles that used in the editor and the frontend, or only in the editor. These functions ensure the correct styles are loaded in the correct place.

Props pento.

Merges [43812] to trunk.

See #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44157 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-14 03:35:55 +00:00
Jonathan Desrosiers
8909554d2e Script loader: Adjust JS packages registration.
Adjusts the packages registration after [43723]:

    Combine the different registration functions into one `wp_default_packages` function. To reach this goal move the prefix logic into a function so it can be called from different locations. Use a static variable there to prevent duplicate inclusion of `version.php`.

    Call this function from the `wp_default_scripts` action by registering it as a default filter.

    Combine some of the logic in `_WP_Editors::print_tinymce_scripts` into `wp_register_tinymce_scripts`. The logic to force an uncompressed TinyMCE script file stays in `_WP_Editors::force_uncompressed_tinymce` because that logic is very specific to the classic editor.

    The script handle `wp-tinymce` is now a dependency of the editor script handle. In combination with the previous item, this makes the classic editor work.

    Adjust the syntax of the script paths to be more consistent with other WordPress code.

    Always use "production" mode for the media files to prevent people from inadvertently committing development files.

Props pento, omarreiss, atimmer.

Merges [43738] into trunk.

Fixes #45065.

git-svn-id: https://develop.svn.wordpress.org/trunk@44115 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-13 17:26:09 +00:00
Sergey Biryukov
244f435e22 Script/Style Dependencies: Make sure that inline scripts for handles without a source are printed.
See [36550] for `WP_Styles`.

Props bpayton.
Fixes #44551.

git-svn-id: https://develop.svn.wordpress.org/trunk@43565 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-11 17:41:29 +00:00
Ian Dunn
c896326c55 External Libraries: Test for MEjs files in src instead of build.
The `build` task doesn't get run during TravisCI jobs, so the `build` folder doesn't exist in that context. Because of that, the test added in r42762 was failling.

Checking for the files in `src` instead achieves the same goal as that commit, but should pass in Travis.

See #43101
See https://wordpress.slack.com/archives/C02RQBWTW/p1519742993000615


git-svn-id: https://develop.svn.wordpress.org/trunk@42763 602fd350-edb4-49c9-b593-d223f7449a82
2018-02-28 00:25:08 +00:00
Ian Dunn
fde455a89f External Libraries: Test that MediaElement SWF files remain deleted.
The files were removed from Core in r42462 because they're no longer necessary, and have a history of security issues. They remain upstream, though, so this test makes it explicitly clear that they should not be added back in the future without careful consideration and discussion with the Security team.

`Tests_Admin_IncludesUpdateCore::test_new_files_are_not_in_old_files_array_compiled()` would already catch files with the exact same name, but this test will also catch files with new names, just to be extra cautious.

Props iandunn, ocean90, SergeyBiryukov
Fixes 43101


git-svn-id: https://develop.svn.wordpress.org/trunk@42762 602fd350-edb4-49c9-b593-d223f7449a82
2018-02-27 14:37:15 +00:00
Sergey Biryukov
59e1b7318d Tests: Correct erroneous @covers and @use tags.
Props jipmoors.
Fixes #43203.

git-svn-id: https://develop.svn.wordpress.org/trunk@42636 602fd350-edb4-49c9-b593-d223f7449a82
2018-02-01 16:08:04 +00:00
Gary Pendergast
8f95800d52 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-30 23:09:33 +00:00
Weston Ruter
a411d5571a Code Editor: Fix phpunit tests related to gutters after [41974].
See #12423.


git-svn-id: https://develop.svn.wordpress.org/trunk@41994 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-24 16:57:10 +00:00
Weston Ruter
faeac43629 Code Editor: Add unit tests for wp_enqueue_code_editor() and WP_Widget_Custom_HTML.
Props ryotsun.
See #12423.
Fixes #41871.


git-svn-id: https://develop.svn.wordpress.org/trunk@41855 602fd350-edb4-49c9-b593-d223f7449a82
2017-10-13 17:57:38 +00:00
John Blackbourn
5ab2a22a38 Build/Test Tools: Utilise assertFileExists() and assertFileNotExists() in more places.
See #38716


git-svn-id: https://develop.svn.wordpress.org/trunk@39173 602fd350-edb4-49c9-b593-d223f7449a82
2016-11-08 23:49:11 +00:00
Dominik Schilling (ocean90)
62bd8ecdd7 External Libraries: Update Backbone to version 1.3.3.
Changelog: https://cdn.rawgit.com/jashkenas/backbone/1.3.3/index.html#changelog
Diff: https://github.com/jashkenas/backbone/compare/1.2.3...1.3.3

Includes a unit test to ensure that the minified version doesn't include `sourceMappingURL`.

Props adamsilverstein.
Fixes #37099.

git-svn-id: https://develop.svn.wordpress.org/trunk@37723 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 09:26:06 +00:00
Jeremy Felt
f98744ec86 Ensure consistent dependency order when using wp_add_inline_script()
This disables the concatenation of remaining enqueued scripts once `wp_add_inline_script()` is invoked, which allows us to reliably print these scripts and their before/after inline scripts in the desired order.

Props gitlost, azaozz, swisspidy, ocean90.
Fixes #36392.


git-svn-id: https://develop.svn.wordpress.org/trunk@37171 602fd350-edb4-49c9-b593-d223f7449a82
2016-04-10 03:32:47 +00:00
Dominik Schilling (ocean90)
00e87b40c8 Dependencies: Improve group processing of script dependencies.
This is a follow-up to [36604].

When processing dependencies `$this->group` will be the minimum of the script's registered group and all preceding siblings. This is wrong because only a scripts ancestors in the dependency chain should affect where it is loaded. Effectively `$this->group` introduced a form of global state which potentially corrupted the group of dependencies. Sorting covers up this problem.
The issue in #35873 was that script were not moving their dependencies to a lower group when necessary.

The fix:
* In `WP_Dependencies::all_deps()` pass the new `$group` value to `WP_Dependencies::all_deps()`. Previously the wrong value was passed because the parent script could have moved with `WP_Scripts::set_group()`.
* In `WP_Scripts::all_deps()` pass the `$group` parameter to `WP_Dependencies::all_deps()` so it doesn't always use `false` for `$group`. Same for `WP_Styles::all_deps()`.

Props stephenharris, gitlost.
Fixes #35956.

git-svn-id: https://develop.svn.wordpress.org/trunk@36871 602fd350-edb4-49c9-b593-d223f7449a82
2016-03-06 19:49:54 +00:00
Dominik Schilling (ocean90)
3a836ea224 Styles: Clarify the allowed values for the $media parameter of wp_register_style()/wp_enqueue_style().
Adds unit test.

Fixes #35921.

git-svn-id: https://develop.svn.wordpress.org/trunk@36649 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 20:40:43 +00:00
Pascal Birchler
0e13a57288 Script Loader: Introduce wp_add_inline_script().
This new function can be used to add inline JavaScript before and after enqueued scripts, just like `wp_add_inline_style()` works for CSS.

Props atimmer, abiralneupane, ocean90, swissspidy.
Fixes #14853.

git-svn-id: https://develop.svn.wordpress.org/trunk@36633 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-23 16:43:41 +00:00
Dominik Schilling (ocean90)
6e493b1713 Script Loader: Fix missing script output when the groups of dependencies are different.
Aka: Don't lose the grandchild.

Props gitlost, ocean90.
Fixes #35873.

git-svn-id: https://develop.svn.wordpress.org/trunk@36604 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-20 22:10:01 +00:00
Dominik Schilling (ocean90)
5f9d1fa799 Tests: Test that jQuery can be moved into footer after [36550].
Props gitlost.
See #25247.

git-svn-id: https://develop.svn.wordpress.org/trunk@36596 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-20 16:16:35 +00:00
Dominik Schilling (ocean90)
548a18059c Tests: Add a test for testing wp_enqueue_script() with an alias handle in the footer.
Props kovshenin.
See #35643.

git-svn-id: https://develop.svn.wordpress.org/trunk@36559 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 19:52:42 +00:00
Dominik Schilling (ocean90)
59747aa6b9 Script/Style Dependencies: Make sure that inline styles for handles without a source are printed.
This prevents breaking plugins which are adding inline styles to the `wp-admin` handle after [36341].

Props dd32, ocean90.
Fixes #35229.

git-svn-id: https://develop.svn.wordpress.org/trunk@36550 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 17:10:53 +00:00
Dominik Schilling (ocean90)
149686b424 Tests: Indent test_wp_register_script() with tabs.
git-svn-id: https://develop.svn.wordpress.org/trunk@36549 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 16:07:01 +00:00
Dominik Schilling (ocean90)
de9d091e76 Tests: Indent test_wp_register_style() with tabs.
git-svn-id: https://develop.svn.wordpress.org/trunk@36547 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-17 15:36:20 +00:00
John Blackbourn
39639c79da Add a return value to wp_register_script() and wp_register_style() which matches the return value of WP_Dependencies::add().
Props katzwebdesign, pareshradadiya, DrewAPicture.

Fixes #31126


git-svn-id: https://develop.svn.wordpress.org/trunk@32483 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-10 19:56:15 +00:00
Gary Pendergast
ae391ec226 Add emoji support, with Twemoji fallback.
Replace exisiting smilies with equivalent emoji, or with shiny new smiley images where no emoji existed.

Props batmoo, joen and mkaz for the original plugin upon which this is based.

Props pento, iseulde, kraftbj and peterwilsoncc for making the internet's dreams come true.

See #31242



git-svn-id: https://develop.svn.wordpress.org/trunk@31733 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-11 22:48:16 +00:00
Andrew Ozz
9391d4f572 Separate the tests for IE conditional comments support in WP_Scripts. Props valendesigns, see 16024.
git-svn-id: https://develop.svn.wordpress.org/trunk@31317 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-31 20:40:49 +00:00
Andrew Ozz
f18854e866 Add support for IE conditional comments for WP_Scripts to match the functionality of WP_Styles, including unit tests. Props filosofo, aaroncampbell, ethitter, georgestephanis, valendesigns. Fixes #16024.
git-svn-id: https://develop.svn.wordpress.org/trunk@31223 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-17 01:36:55 +00:00
Scott Taylor
d699ce8b13 Ensure that inline styles attached to conditional stylesheets are also conditional.
Adds unit test.

Props georgestephanis.
Fixes #29180.


git-svn-id: https://develop.svn.wordpress.org/trunk@31031 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-03 04:09:12 +00:00
Boone Gorges
0b9a21b451 Remove skipped tests for unimplemented JS plural functions.
The tests have been added as a patch for the original ticket, #22229.

Props MikeHansenMe.
See #22229.

git-svn-id: https://develop.svn.wordpress.org/trunk@30517 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-22 20:11:10 +00:00
Sergey Biryukov
79734b0677 Update expected results in wp_add_inline_style() unit tests after [29958].
props georgestephanis.
see #30032.

git-svn-id: https://develop.svn.wordpress.org/trunk@29967 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-19 21:23:32 +00:00
Scott Taylor
77ee35c4eb wp_script_is( ..., 'enqueued' ) needs to check dependencies recursively - a single item's dependencies may only be a subset of the full dependency tree. Adds a new method on WP_Dependencies called ->recurse_deps().
Adds unit test.

Props wonderboymusic, SergeyBiryukov, mikejolley.
Fixes #28404.


git-svn-id: https://develop.svn.wordpress.org/trunk@29252 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-20 00:28:57 +00:00
Scott Taylor
3c671f031e When setting WP_TESTS_FORCE_KNOWN_BUGS to true, it is preferable that some forced tests are still skipped when they call classes or functions that do not exist, producing fatal errors.
Fixes #26248.



git-svn-id: https://develop.svn.wordpress.org/trunk@26370 602fd350-edb4-49c9-b593-d223f7449a82
2013-11-25 22:49:51 +00:00
Andrew Nacin
5e119ca3b4 Revert [25202] and enforce that wp_add_inline_style() does not want <style> tags.
Prior to 3.7, these tags were not printed (and thus needed to be provided), but only in the admin and when concatenation was enabled. They should never be required. Strip them when we find them and issue a notice for incorrect usage.

props atimmer, georgestephanis.
fixes #24813.


git-svn-id: https://develop.svn.wordpress.org/trunk@25786 602fd350-edb4-49c9-b593-d223f7449a82
2013-10-15 14:34:33 +00:00
Andrew Nacin
5ceab9b1e3 Test runner: Add @expectedIncorrectUsage to trap _doing_it_wrong() calls.
see #24813, #25282.


git-svn-id: https://develop.svn.wordpress.org/trunk@25785 602fd350-edb4-49c9-b593-d223f7449a82
2013-10-15 14:30:02 +00:00
Scott Taylor
62b7214706 Avoid an undefined index error in tests/phpunit/tests/dependencies/styles.php
See #25282.



git-svn-id: https://develop.svn.wordpress.org/trunk@25376 602fd350-edb4-49c9-b593-d223f7449a82
2013-09-12 04:13:11 +00:00