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

Find html elements by class #1933

Merged
merged 2 commits into from
Jan 27, 2019
Merged

Find html elements by class #1933

merged 2 commits into from
Jan 27, 2019

Conversation

kii-dot
Copy link
Contributor

@kii-dot kii-dot commented Dec 10, 2018

Fixes #1929.

@ljharb This is the the test case that I wrote. Could you check and see if it's the right idea before I continue writing it for all the other elements?

packages/enzyme-test-suite/test/ReactWrapper-spec.jsx Outdated Show resolved Hide resolved
packages/enzyme-test-suite/test/ReactWrapper-spec.jsx Outdated Show resolved Hide resolved
packages/enzyme/src/selectors.js Outdated Show resolved Hide resolved
packages/enzyme-test-suite/test/ReactWrapper-spec.jsx Outdated Show resolved Hide resolved
packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx Outdated Show resolved Hide resolved
packages/enzyme-test-suite/test/ReactWrapper-spec.jsx Outdated Show resolved Hide resolved
packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx Outdated Show resolved Hide resolved
packages/enzyme/src/selectors.js Outdated Show resolved Hide resolved
packages/enzyme/src/selectors.js Outdated Show resolved Hide resolved
packages/enzyme-test-suite/test/ReactWrapper-spec.jsx Outdated Show resolved Hide resolved
@ljharb
Copy link
Member

ljharb commented Dec 23, 2018

I've rebased this; I think some things need to be rethought. The current map is needed for tests - of tag names to element constructors - but a similar map is needed in selectors to map from constructor to tag name.

Before making changed, please reset your local branch to match the rebased commit I've pushed up.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a test that the two maps are in fact inverses of each other.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up publishing https://npmjs.com/html-element-map and updated this PR to use it; I'll merge after tests pass.

@ljharb
Copy link
Member

ljharb commented Jan 27, 2019

(linking to aweary/rst-selector-parser#15 as well)

@ljharb ljharb merged commit aa1af32 into enzymejs:master Jan 27, 2019
* @param {RSTNode} root
*/
export function reduceTreeBySelector(selector, root) {
if (typeof selector !== 'string') {
const elements = elementsByConstructor(selector);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pops "Update your Java installation" in IE11 😢
ljharb/html-element-map#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants