Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework: Replace element-closest with registered vendor script #9750

Merged
merged 7 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function gutenberg_register_scripts_and_styles() {
'\'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',
)
)
);
Expand Down Expand Up @@ -846,6 +847,10 @@ function gutenberg_register_vendor_scripts() {
'wp-polyfill-node-contains',
'https://unpkg.com/[email protected]/polyfills/Node/prototype/contains/polyfill.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-element-closest',
'https://unpkg.com/[email protected]/element-closest.js'
);
gutenberg_register_vendor_script(
'wp-polyfill-ecmascript',
'https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.0.0/polyfill' . $suffix . '.js'
Expand Down
90 changes: 43 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@wordpress/i18n": "file:../i18n",
"@wordpress/is-shallow-equal": "file:../is-shallow-equal",
"@wordpress/shortcode": "file:../shortcode",
"element-closest": "^2.0.2",
"hpq": "^1.2.0",
"lodash": "^4.17.10",
"rememo": "^3.0.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/blocks/src/api/raw-handling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* External dependencies
*/
import { flatMap, filter, compact } from 'lodash';
// Also polyfills Element#matches.
import 'element-closest';

/**
* Internal dependencies
Expand Down
1 change: 0 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"clipboard": "^1.7.1",
"diff": "^3.5.0",
"dom-scroll-into-view": "^1.2.1",
"element-closest": "^2.0.2",
"lodash": "^4.17.10",
"memize": "^1.0.5",
"moment": "^2.22.1",
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/autocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import classnames from 'classnames';
import { escapeRegExp, find, filter, map, debounce } from 'lodash';
import 'element-closest';

/**
* WordPress dependencies
Expand Down
1 change: 0 additions & 1 deletion packages/dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"module": "build-module/index.js",
"dependencies": {
"@babel/runtime": "^7.0.0",
"element-closest": "^2.0.2",
"lodash": "^4.17.10"
},
"publishConfig": {
Expand Down
5 changes: 0 additions & 5 deletions packages/dom/src/focusable.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import 'element-closest';

/**
* References:
*
Expand Down
1 change: 0 additions & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"@wordpress/wordcount": "file:../wordcount",
"classnames": "^2.2.5",
"dom-scroll-into-view": "^1.2.1",
"element-closest": "^2.0.2",
"inherits": "^2.0.3",
"lodash": "^4.17.10",
"memize": "^1.0.5",
Expand Down
1 change: 0 additions & 1 deletion packages/editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
last,
} from 'lodash';
import classnames from 'classnames';
import 'element-closest';

/**
* WordPress dependencies
Expand Down
1 change: 0 additions & 1 deletion packages/editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
merge,
noop,
} from 'lodash';
import 'element-closest';

/**
* WordPress dependencies
Expand Down
5 changes: 0 additions & 5 deletions packages/editor/src/utils/dom.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import 'element-closest';

/**
* Given a block client ID, returns the corresponding DOM node for the block,
* if exists. As much as possible, this helper should be avoided, and used only
Expand Down
7 changes: 6 additions & 1 deletion packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.3.0 (Unreleased)

### Improvements

- New flag `--ignore` for `check-licenses` script

## 2.2.1 (2018-09-05)

### Bug Fix
Expand All @@ -8,7 +14,6 @@

- Updated dependencies: `jest`, `npm-package-json-lint` and `read-pkg-up`


## 2.0.0 (2018-07-12)

### Breaking Change
Expand Down
21 changes: 21 additions & 0 deletions packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ This is how you execute those scripts using the presented setup:
* `npm run test:help` - prints all available options to configure unit tests runner.
* `npm run test:watch` - runs all unit tests in the watch mode.

### `wp-scripts check-licenses`

Validates that all dependencies of a project are compatible with the project's own license.

_Example:_

```json
{
"scripts": {
"check-licenses": "wp-scripts check-licenses --prod --gpl2 --ignore=abab",
}
}
```

_Flags_:

- `--prod` (or `--production`): When present, validates only `dependencies` and not `devDependencies`
- `--dev` (or `--development`): When present, validates both `dependencies` and `devDependencies`
- `--gpl2`: Validates against [GPLv2 license compatibility](https://www.gnu.org/licenses/license-list.en.html)
- `--ignore=a,b,c`: A comma-separated set of package names to ignore for validation. This is intended to be used primarily in cases where a dependency's `license` field is malformed. It's assumed that any `ignored` package argument would be manually vetted for compatibility by the project owner.

## Inspiration

This is inspired by [react-scripts](https://www.npmjs.com/package/react-scripts) and [kcd-scripts](https://www.npmjs.com/package/kcd-scripts).
Expand Down
Loading