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

feat(qsa, flatten-tree): abstract Node and Element apis in virtual tree #1562

Merged
merged 11 commits into from
May 24, 2019

Conversation

straker
Copy link
Contributor

@straker straker commented May 10, 2019

I wanted the abstraction layer on the virtual node to be consistent and predictable so you wouldn't have to look at the virtual node implementation to figure out what the thing was called you wanted. I went with prefixing all api names with element and then capitalizing the first letter. Someone suggested mimicking jQuery api names, but they don't have any api names for low-level properties like nodeType, and nodeName, which would mean an inconsistency in naming convention.

Qsa tests used a mock virtual tree, which made it really difficult to test changes to qsa that depend on the virtual tree implementation. So I changed it to use a real virtual tree and then added a test to ensure qsa does not look at the actualNode property (ensuring a DOM-less run).

Linked issue: #1552

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: @WilcoFiers

lib/core/utils/flattened-tree.js Outdated Show resolved Hide resolved
lib/core/utils/flattened-tree.js Outdated Show resolved Hide resolved
lib/core/utils/flattened-tree.js Outdated Show resolved Hide resolved
lib/core/utils/flattened-tree.js Outdated Show resolved Hide resolved
@straker
Copy link
Contributor Author

straker commented May 13, 2019

With hasClass we were now adding functions with logic, so I decided to create a VirtualNode
constructor function so we could have tests around the logic. I also moved the getter functions for isFocusable and tabbableElements to prototype functions so they could be part of the shared prototype rather than one off for each virtual node.

lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/utils/qsa.js Outdated Show resolved Hide resolved
test/core/utils/qsa.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Show resolved Hide resolved
Copy link
Member

@stephenmathieson stephenmathieson left a comment

Choose a reason for hiding this comment

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

LGTM, but I think this one needs another set of eyes. Maybe @WilcoFiers or @JKODU can also review?

Copy link
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

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

One question, and we need the getters back. Sorry, that idea of using getters was mine, I'm not sure it was a good one, but we're stuck with it.

lib/core/utils/qsa.js Outdated Show resolved Hide resolved
lib/checks/keyboard/focusable-content.js Outdated Show resolved Hide resolved
lib/checks/keyboard/focusable-element.js Outdated Show resolved Hide resolved
lib/core/base/virtual-node.js Outdated Show resolved Hide resolved
@straker straker self-assigned this May 24, 2019
@straker straker merged commit 2f2e590 into develop May 24, 2019
@straker straker deleted the qsaDomless branch May 24, 2019 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants