yosinch / editing

document.execCommand in JavaScript for Blink
4 stars 6 forks source link

Should use Node.prototype.contains in EditingContext.prototype.inDocument #53

Open hajimehoshi opened 10 years ago

hajimehoshi commented 10 years ago

See https://developer.mozilla.org/en-US/docs/Web/API/Node.contains

Here is implementation in Blink

bool Node::contains(const Node* node) const {
  if (!node)
    return false;
  return this == node || node->isDescendantOf(this);
}

So, this function can be called |isDescendantOfOrSelf()|. It seems we can get rid of editing.nodes.isDescendatOf by replacing it with |Node.prototype.contains()|.

yosinch commented 10 years ago

Closure compiler has wrong externs for Node.prototype.contains() in ie_dom.js, which accept {Element|null} rather than {Node|null}. So, we should have workaround for this incompatibility.