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

Improve SVGGeometryElement#{isPointInFill,isPointInStroke} examples #35746

Merged
merged 2 commits into from
Feb 2, 2025

Conversation

xBZZZZ
Copy link
Contributor

@xBZZZZ xBZZZZ commented Sep 4, 2024

changed pages:


  • changed examples:
    • don't use pointEl.style.r, pointEl.style.cx, pointEl.style.cy because they don't exist in firefox
    • don't use isPointInFill variable that is not declared in https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/isPointInStroke#javascript
    • use { x: point[0], y: point[1] } instead of new DOMPoint(point[0], point[1]) to show that object class doesn't matter in browsers that support Accepts a DOMPoint as point parameter
    • look different to see region where fill and stroke overlap
  • changed DOMPointDOMPointInit in parameters

What does Normal hit testing rules apply; the value of the pointer-events property on the element determines
whether a point is considered to be within the fill.
mean?
Adding pointer-events="none" or style="pointer-events:none" to big circle has no effect.

@github-actions github-actions bot added Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed labels Sep 4, 2024
Copy link
Contributor

github-actions bot commented Sep 4, 2024

Preview URLs

(comment last updated: 2025-02-02 20:01:45)

@Josh-Cena
Copy link
Member

@xBZZZZ Are you going to complete this soon?

@xBZZZZ
Copy link
Contributor Author

xBZZZZ commented Oct 29, 2024

@xBZZZZ Are you going to complete this soon?

when this question (duplicate of first comment) gets answered:

What does Normal hit testing rules apply; the value of the pointer-events property on the element determines
whether a point is considered to be within the fill.
mean?
Adding pointer-events="none" or style="pointer-events:none" to big circle has no effect.

https://jsbin.com/kopefuzace/1/edit?html,js,output
https://github.com/orgs/mdn/discussions/737

@Josh-Cena
Copy link
Member

I looked into this question. Apparently it was in the old spec: w3c/svgwg#416, but then pointer-events no longer impacts these two properties in around 2018, before all other browsers ship it, and Chrome never had pointer-events affecting these two methods. So we can safely remove them.

better parameter description and examples (work in firefox!)
Comment on lines 88 to 91
const pathEl = document.createElementNS(
"http://www.w3.org/2000/svg",
"path",
);
Copy link
Contributor

Choose a reason for hiding this comment

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

[mdn-linter] reported by reviewdog 🐶

Suggested change
const pathEl = document.createElementNS(
"http://www.w3.org/2000/svg",
"path",
);
const pathEl = document.createElementNS("http://www.w3.org/2000/svg", "path");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what about

  const pointEl = document.createElementNS(
    "http://www.w3.org/2000/svg",
    "circle",
  );

?

Copy link
Member

Choose a reason for hiding this comment

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

@xBZZZZ It's because the pathEl declaration is shorter by a few characters, so it fits into an 80-character line, but pointEl does not.

Comment on lines 88 to 91
const pathEl = document.createElementNS(
"http://www.w3.org/2000/svg",
"path",
);
Copy link
Contributor

Choose a reason for hiding this comment

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

[mdn-linter] reported by reviewdog 🐶

Suggested change
const pathEl = document.createElementNS(
"http://www.w3.org/2000/svg",
"path",
);
const pathEl = document.createElementNS("http://www.w3.org/2000/svg", "path");

@xBZZZZ xBZZZZ marked this pull request as ready for review February 2, 2025 08:23
@xBZZZZ xBZZZZ requested a review from a team as a code owner February 2, 2025 08:23
@xBZZZZ xBZZZZ requested review from sideshowbarker and removed request for a team February 2, 2025 08:23
@Josh-Cena Josh-Cena changed the title SVGGeometryElement.prototype.{isPointInFill,isPointInStroke} Improve SVGGeometryElement#{isPointInFill,isPointInStroke} examples Feb 2, 2025
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

The new examples are a huge improvement in every way. Thank you! I just pushed a little change to avoid mentioning DOMPointInit, because we don't document dictionaries on MDN.

@Josh-Cena Josh-Cena merged commit 1e801c9 into mdn:main Feb 2, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants