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

Bounds must be non-empty #856

Merged
merged 3 commits into from
Nov 7, 2018
Merged

Bounds must be non-empty #856

merged 3 commits into from
Nov 7, 2018

Conversation

chancancode
Copy link
Contributor

@chancancode chancancode commented Sep 27, 2018

💣 contains breaking changes

The Bounds object represents a inclusive range. That is, the bounds is referring to the range in DOM including the firstNode() and the lastNode(). Therefore, it does not ever make sense for those endpoints to be null. (Technically, (parent, null, null) is a valid way to represent an empty range. However, in practice we do not have a use case for this, and every use of null were actual bugs.)

This is technically a breaking change, but then again, if null were passed today it's likely a bug, and if the consuming side was checking for null it's likely just deadcode that will never execute in practice.

@chancancode chancancode force-pushed the fix-bounds branch 2 times, most recently from 3a96c77 to 84c6638 Compare September 27, 2018 18:28
* Inline `insertHTMLBefore` helper and stop exporting it (technically breaking)
* Align types in signatures
* Unify the handling of empty content
let first = prev ? prev.nextSibling : parent.firstChild;
let last = reference ? reference.previousSibling : parent.lastChild;

return new ConcreteBounds(parent, first, last);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bug (similar in nature to #852) in FastBoot. Since you don't normally run updates there I don't know how much this matters (i.e. should I split this into a BUGFIX PR and release that separately).

The `Bounds` object represents a _inclusive_ range. That is, the bounds
is referring to the range in DOM _including_ the `firstNode()` and the
`lastNode()`. Therefore, it does not ever make sense for those endpoints
to be `null`. (Technically, `(parent, null, null)` is a valid way to
reprsent an _empty_ range. However, in practice we do not have a use case
for this, and every use of `null` were actual bugs.)

This is technically a breaking change, but then again, if `null` were
passed today it's likely a bug, and if the consuming side was checking for
`null` it's likely just deadcode that will never execute in practice.
@chancancode chancancode changed the title [WIP] Fix Bounds Bounds must be non-empty Sep 28, 2018
if (parent.namespaceURI !== svgNamespace) {
return super.insertHTMLBefore(parent, nextSibling, html);
}

return fixSVG(parent, div, html, nextSibling);
// TODO: why are these casts okay???
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

The mental model is that DOMChanges is dealing with live elements. Updating doesn't mean anything in SSR case.

return new ConcreteBounds(_parent, comment, comment);
}

// TODO why are these casts okay???
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

I realize this is breaking because then interface is changing, but do we expect consumers to actual require changes to update? I don’t think Ember or Glimmer.js are manually creating these bounds objects, are they?

@chancancode
Copy link
Contributor Author

I don’t think so. I also removed some exports too, but I don’t know of any consumers

@chancancode
Copy link
Contributor Author

On the other hand, it doesn’t cost anything to bump the minor

This commit finishes the job iof making the SimpleDOM abstraction the
full abstraction for DOM implementations in Glimmer.

It adds a subset of the standard insertAdjacentHTML API to SimpleDOM,
which is expected to be present in all DOM implementations provided to
Glimmer.
Copy link
Contributor Author

@chancancode chancancode left a comment

Choose a reason for hiding this comment

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

last commit lgtm

@wycats wycats merged commit caa28ac into master Nov 7, 2018
@wycats wycats deleted the fix-bounds branch November 7, 2018 18:56
@tomdale tomdale added the bug label Nov 29, 2018
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.

5 participants