Skip to content

IntersectionObserverEntry should have a constructor #33

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

Closed
domenic opened this issue Oct 7, 2015 · 6 comments
Closed

IntersectionObserverEntry should have a constructor #33

domenic opened this issue Oct 7, 2015 · 6 comments

Comments

@domenic
Copy link

domenic commented Oct 7, 2015

IntersectionObserverEntry objects are not exotic and there's no reason to keep their creation magic that I can see. They should have a constructor. I'd suggest one that takes a dictionary

dictionary IntersectionObserverEntryInit {
  required DOMHighResTimeStamp time;
  required DOMRectInit rootBounds;
  required DOMRectInit boundingClientRect;
  required DOMRectInit intersectionRect;
  required Element target;
}

You could try to add smart defaults instead of making everything required but that doesn't seem worth the trouble.

@mpb
Copy link
Collaborator

mpb commented Oct 7, 2015

Hm, would JavaScript really want to create IntersectionObserverEntry objects?
MutationRecord (http://www.w3.org/TR/dom/#interface-mutationrecord) doesn't seem to provide one either.
Or is this a newer standard for specs that MutationObserver predates?

@domenic
Copy link
Author

domenic commented Oct 7, 2015

Or is this a newer standard for specs that MutationObserver predates?

Mostly this. Having objects be constructed magically by the platform should be reserved for truly special cases.

One example use case is mocking libraries.

@mpb
Copy link
Collaborator

mpb commented Oct 7, 2015

Sure. And it's preferred to do an initialization dictionary versus listing each parameter?

@domenic
Copy link
Author

domenic commented Oct 7, 2015

For something with this many properties, none of which are clearly primary, yeah, I think that's the way to go.

@mpb
Copy link
Collaborator

mpb commented Oct 7, 2015

Closed via #44

@RByers
Copy link
Contributor

RByers commented Mar 4, 2017

Unfortunately it looks like we never implemented the constructor in blink ☹️

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

No branches or pull requests

3 participants