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 dom.js to have similar functions be close to each other and have more accurate names. #20717

Merged
merged 9 commits into from Feb 12, 2019

Conversation

delima02
Copy link
Contributor

@delima02 delima02 commented Feb 7, 2019

  • Move ancestorElements and ancestorElementsByTag close to other similar functions in dom.js.
  • Rename closestByTag and closestBySelector to closestAncestorElementByTag and closestAncestorElementBySelector, respectively.
  • Have all child related functions be next to all ancestor related functions in dom.js.

📖 ♻️

@choumx @jridgewell

@ghost
Copy link

ghost commented Feb 7, 2019

This pull request introduces 2 alerts when merging 788d692 into 9f78741 - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@ghost
Copy link

ghost commented Feb 7, 2019

This pull request introduces 2 alerts when merging 1230192 into 9f78741 - view on LGTM.com

new alerts:

  • 2 for Invocation of non-function

Comment posted by LGTM.com

@@ -310,7 +310,8 @@ export class Navigation {
if (e.defaultPrevented) {
return;
}
const target = closestByTag(dev().assertElement(e.target), 'A');
const target =
closestAncestorElementByTag(dev().assertElement(e.target), 'A');

Choose a reason for hiding this comment

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

Nit: This indentation is wrong.

const element = dev().assertElement(e.target);
const target = closestAncestorElementByTag(element, 'A');

Check out the Google JS style guide (we don't follow this exactly): https://google.github.io/styleguide/jsguide.html

@jridgewell jridgewell merged commit fe22080 into ampproject:master Feb 12, 2019
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
…nd have more accurate names. (ampproject#20717)

* Move ancestorElementsByTag closer to similar functions.

* Rename 'closest' functions in dom.js to more accurate nomenclature.

* Have child-related functions be next to ancestor-related ones in dom.js.

* Make all usages of the renamed functions use the correct names.

* Make all usages of the renamed functions use the correct names.

* Lint all changes in this branch.

* Update usages of closestAncestorElementBySelector missed in past commits

* Indentation formatting at navigation.js.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants