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

Issue/1625 implement element closest #1626

Merged
merged 4 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 87 files
+2 −2 .travis.yml
+4 −1 babel.config.js
+9 −0 docs/contributors/getting-started.md
+13 −0 docs/contributors/testing-overview.md
+8 −8 docs/designers-developers/designers/block-design.md
+13 −9 docs/designers-developers/developers/tutorials/javascript/js-build-setup.md
+2 −0 docs/designers-developers/developers/tutorials/javascript/readme.md
+1 −1 gutenberg.php
+417 −7 package-lock.json
+3 −1 package.json
+6 −0 packages/api-fetch/CHANGELOG.md
+58 −42 packages/api-fetch/src/middlewares/preloading.js
+51 −3 packages/api-fetch/src/middlewares/test/preloading.js
+12 −12 packages/block-editor/src/components/contrast-checker/test/__snapshots__/index.js.snap
+4 −0 packages/block-editor/src/components/rich-text/README.md
+2 −0 packages/block-editor/src/components/rich-text/index.js
+5 −2 packages/block-editor/src/store/actions.js
+10 −1 packages/block-editor/src/store/effects.js
+2 −1 packages/block-editor/src/store/selectors.js
+1 −0 packages/block-library/src/audio/index.js
+8 −0 packages/block-library/src/cover/edit.js
+1 −0 packages/block-library/src/cover/index.js
+1 −1 packages/block-library/src/cover/shared.js
+5 −1 packages/block-library/src/embed/core-embeds.js
+1 −1 packages/block-library/src/image/edit.native.js
+2 −1 packages/block-library/src/image/editor.scss
+15 −21 packages/block-library/src/navigation-link/edit.js
+7 −2 packages/block-library/src/navigation/edit.js
+5 −0 packages/block-library/src/navigation/index.js
+14 −12 packages/block-library/src/navigation/index.php
+57 −4 packages/block-library/src/navigation/style.scss
+2 −1 packages/block-library/src/preformatted/block.json
+3 −6 packages/block-library/src/preformatted/edit.js
+1 −1 packages/block-library/src/social-link/social-list.js
+2 −1 packages/block-library/src/verse/block.json
+1 −0 packages/block-library/src/verse/edit.js
+1 −1 packages/block-library/src/verse/index.js
+92 −0 packages/blocks/src/api/raw-handling/html-formatting-remover.js
+2 −0 packages/blocks/src/api/raw-handling/paste-handler.js
+110 −0 packages/blocks/src/api/raw-handling/test/html-formatting-remover.js
+0 −1 packages/components/package.json
+13 −7 packages/components/src/base-control/index.js
+6 −10 packages/components/src/clipboard-button/index.js
+1 −1 packages/components/src/popover/stories/index.js
+1 −1 packages/components/src/tab-panel/stories/index.js
+3 −0 packages/components/src/toolbar-button/style.scss
+2 −2 packages/components/src/utils/colors.js
+11 −1 packages/core-data/src/reducer.js
+209 −1 packages/core-data/src/test/reducer.js
+1 −8 packages/e2e-test-utils/src/transform-block-to.js
+10 −13 packages/e2e-tests/config/setup-test-framework.js
+1 −1 packages/e2e-tests/fixtures/block-transforms.js
+8 −0 packages/e2e-tests/specs/editor/blocks/__snapshots__/preformatted.test.js.snap
+14 −0 packages/e2e-tests/specs/editor/blocks/preformatted.test.js
+38 −0 packages/e2e-tests/specs/editor/various/change-detection.test.js
+4 −2 packages/e2e-tests/specs/editor/various/fullscreen-mode.test.js
+0 −561 packages/e2e-tests/specs/experimental/__snapshots__/block-transforms.test.js.snap
+0 −192 packages/e2e-tests/specs/experimental/block-transforms.test.js
+2 −0 packages/edit-post/src/components/header/more-menu/index.js
+43 −0 packages/edit-post/src/components/header/writing-menu/index.js
+2 −29 packages/edit-post/src/components/layout/style.scss
+2 −23 packages/edit-post/src/components/options-modal/index.js
+1 −2 packages/edit-post/src/components/options-modal/options/base.js
+0 −5 packages/edit-post/src/components/options-modal/style.scss
+0 −19 packages/edit-post/src/components/options-modal/test/__snapshots__/index.js.snap
+7 −0 packages/edit-widgets/src/components/layout/index.js
+40 −31 packages/edit-widgets/src/components/widget-area/index.js
+2 −3 packages/edit-widgets/src/components/widget-areas/index.js
+5 −2 packages/editor/src/store/selectors.js
+2 −0 packages/rich-text/README.md
+18 −4 packages/rich-text/src/component/index.js
+49 −17 packages/rich-text/src/create.js
+7 −4 packages/rich-text/src/to-html-string.js
+2 −1 packages/rich-text/src/to-tree.js
+6 −1 storybook/.babelrc
+5 −0 storybook/README.md
+4 −2 storybook/config.js
+3,902 −0 storybook/test/__snapshots__/index.js.snap
+29 −0 storybook/test/index.js
+2 −20 test/integration/fixtures/apple-out.html
+1 −1 test/integration/fixtures/classic-out.html
+2 −10 test/integration/fixtures/evernote-out.html
+1 −2 test/integration/fixtures/markdown-out.html
+3 −23 test/integration/fixtures/ms-word-out.html
+2 −10 test/integration/fixtures/ms-word-styled-out.html
+6 −0 test/unit/config/register-context.js
+1 −0 test/unit/jest.config.js
15 changes: 15 additions & 0 deletions src/jsdom-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ Node.prototype.insertBefore = function( /* Node */ newChild, /* Node*/ refChild
*/
Element.prototype.matches = Element.prototype.matchesSelector;

/*
* Implementation of Element.prototype.closest that it's missing from the jsdom-jscore fork we're using.
* See https://github.com/wordpress-mobile/gutenberg-mobile/issues/1625
*/
Element.prototype.closest = function( selector ) {
let el = this;
while ( el ) {
if ( el.matches( selector ) ) {
return el;
}
el = el.parentElement;
}
return null;
};

/**
* Helper function to check if a node implements the NonDocumentTypeChildNode
* interface
Expand Down