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

Using document and window global variables won't cover all cases #156

Closed
quangbuule opened this issue Jul 7, 2016 · 1 comment · Fixed by #188
Closed

Using document and window global variables won't cover all cases #156

quangbuule opened this issue Jul 7, 2016 · 1 comment · Fixed by #188

Comments

@quangbuule
Copy link

Hi,
I can see that we are replying to window and document variables, that won't be great for some edge cases.

For example on this instance:
https://github.com/facebook/fbjs/blob/master/src/__forks__/Style.js#L51

var Style = {
  /**
   * Gets the style property for the supplied node. This will return either the
   * computed style, if available, or the declared style.
   *
   * @param {DOMNode} node
   * @param {string} name Style property name.
   * @return {?string} Style property value.
   */
  get: getStyleProperty,

  /**
   * Determines the nearest ancestor of a node that is scrollable.
   *
   * NOTE: This can be expensive if used repeatedly or on a node nested deeply.
   *
   * @param {?DOMNode} node Node from which to start searching.
   * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
   */
  getScrollParent: function(node) {
    if (!node) {
      return null;
    }
    while (node && node !== document.body) {
      if (_isNodeScrollable(node, 'overflow') ||
          _isNodeScrollable(node, 'overflowY') ||
          _isNodeScrollable(node, 'overflowX')) {
        return node;
      }
      node = node.parentNode;
    }
    return window;
  },

};

then Style.getScrollParent won't work on the following example:

var iframeEl = document.getElementById('some_iframe');
var scrollParentEl = Style.getScrollParent(iframeEl.contentWindow.document.getElementById('some_element'));
@sophiebits
Copy link
Contributor

Yup. If this is causing a problem in some Facebook project using fbjs, feel free to send a pull request. (If not, we don't have the time to support other uses of fbjs – sorry.)

acusti added a commit to brandcast/fbjs that referenced this issue Sep 28, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Sep 28, 2016
acusti pushed a commit to brandcast/fbjs that referenced this issue Sep 28, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Sep 28, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Sep 28, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Oct 6, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Oct 6, 2016
acusti pushed a commit to brandcast/fbjs that referenced this issue Oct 6, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Oct 6, 2016
acusti added a commit to brandcast/fbjs that referenced this issue Oct 6, 2016
sophiebits pushed a commit that referenced this issue Oct 7, 2016
* [fbjs] Use relative document and window (#156)

* [fbjs] Support nested browsing contexts (#156)

* [fbjs] Test getActiveElement api change (#156)
acusti added a commit to brandcast/fbjs that referenced this issue Mar 16, 2017
* [fbjs] Use relative document and window (facebook#156)

* [fbjs] Support nested browsing contexts (facebook#156)

* [fbjs] Test getActiveElement api change (facebook#156)
zpao pushed a commit that referenced this issue Mar 21, 2017
* [fbjs] Use relative document and window (#156)

* [fbjs] Support nested browsing contexts (#156)

* [fbjs] Test getActiveElement api change (#156)
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

Successfully merging a pull request may close this issue.

2 participants