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

refactor: commons.color.getBackgroundColor method #1451

Merged
merged 13 commits into from
Apr 25, 2019
Merged

Conversation

jeeyyy
Copy link
Contributor

@jeeyyy jeeyyy commented Mar 20, 2019

Refactoring this function, to tackle the next piece of work, which is to enhance background color computation with psuedo-element consideration, which will end up being another code path with in this function.

What happened here:

  • Split commonly called functions to separate utility functions
  • General & quick clean-up
  • Removed dom.isOpaque as it was not used

Closes issue:

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: Steve

@jeeyyy jeeyyy requested a review from a team as a code owner March 20, 2019 15:58
straker
straker previously approved these changes Mar 21, 2019
Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

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

LGTM. I was just wondering if we need tests for the functions that got moved to their own file?

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.

Tests please

@jeeyyy
Copy link
Contributor Author

jeeyyy commented Mar 22, 2019

Yup, on the case.

@jeeyyy jeeyyy changed the title refactor: commons.color.getBackgroundColor method [WIP] refactor: commons.color.getBackgroundColor method Mar 22, 2019
@jeeyyy jeeyyy changed the title [WIP] refactor: commons.color.getBackgroundColor method refactor: commons.color.getBackgroundColor method Apr 4, 2019
test/commons/color/element-has-background-image.js Outdated Show resolved Hide resolved
lib/core/utils/get-coordinates-from-rect.js Outdated Show resolved Hide resolved
lib/core/utils/get-coordinates-from-rect.js Outdated Show resolved Hide resolved
lib/commons/color/get-background-color.js Show resolved Hide resolved
lib/commons/color/element-has-background-image.js Outdated Show resolved Hide resolved
lib/commons/color/get-background-color.js Show resolved Hide resolved
lib/commons/color/get-background-color.js Outdated Show resolved Hide resolved
@jeeyyy jeeyyy requested a review from WilcoFiers April 15, 2019 12:59
@jeeyyy jeeyyy dismissed WilcoFiers’s stale review April 15, 2019 12:59

Updated. Please review again.

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.

Tests are failing. Please fix before I review.

@CLAassistant
Copy link

CLAassistant commented Apr 16, 2019

CLA assistant check
All committers have signed the CLA.

/* This is essential to stop mocha reporter created anchors from making the document overflow, mainly along the x-axis */
#mocha h1 a {
overflow-wrap: break-word;
word-wrap: break-word;
Copy link
Member

Choose a reason for hiding this comment

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

Weird indentation here. Maybe we should run Prettier over our HTML too?

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment wasn't resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Github decides to show it this way 🤔

/* This is essential to stop mocha reporter created anchors from making the document overflow, mainly along the x-axis */
#mocha h1 a {
overflow-wrap: break-word;
word-wrap: break-word;
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment wasn't resolved.

const nodeName = elm.nodeName.toUpperCase();

if (graphicNodes.includes(nodeName)) {
axe.commons.color.incompleteData.set('bgColor', 'imgNode');
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing tests for imcompleteData.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

const hasGradient = /gradient/.test(bgImageStyle);
axe.commons.color.incompleteData.set(
'bgColor',
hasGradient ? 'bgGradient' : 'bgImage'
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing tests for imcompleteData.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* @param {Element} elm
* @return {Array}
*/
color.filteredRectStack = function(elm) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change, please put this back on the color namespace. Apologies, I missed this in my first review round.

@jeeyyy jeeyyy merged commit d25cad8 into develop Apr 25, 2019
@jeeyyy jeeyyy deleted the refactor-color-fns branch April 25, 2019 15:20
stephenmathieson added a commit to mohanraj-r/axe-core that referenced this pull request May 10, 2019
* develop: (50 commits)
  docs: add jsdom example and tests (dequelabs#1530)
  fix(aria-valid-attr-value): allow aria-owns to pass when element is not in the DOM (dequelabs#1526)
  fix(isSkipLink): cache first page link (dequelabs#1525)
  chore: update Babel dependencies (dequelabs#1527)
  chore(package): Update karma to version 4.1.0 (dequelabs#1528)
  feat: Improve perf of axe.run [WWD-1821] (dequelabs#1503)
  fix(prettier): ignore generated api doc files (dequelabs#1522)
  fix(skip-link,region): Allow multiple skiplinks at page top (dequelabs#1496)
  fix(raw-reporter): do not output `DqElement`s (dequelabs#1513)
  fix: Scroll state had top and left properties flipped (dequelabs#1469)
  refactor: commons.color.getBackgroundColor method (dequelabs#1451)
  fix(aria-valid-attr-value): allow aria-controls to pass when element is not in the DOM
  chore: Update husky to the latest version 🚀 (dequelabs#1514)
  style: format HTML files with Prettier (dequelabs#1508)
  test: Fix invalid test html (dequelabs#1502)
  feat(rule): Inline text spacing must be adjustable with custom stylesheets (dequelabs#1446)
  chore: Remove version number from axe.d.ts (dequelabs#1499)
  chore: Update make-dir to the latest version 🚀 (dequelabs#1465)
  fix: Exclude  iframe for html-has-lang rule (Issue 1424) (dequelabs#1430)
  feat(utils): add support for complex CSS selectors (dequelabs#1494)
  ...
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.

6 participants