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

width() Issue - works with jQuery #1289

Open
cwbeck opened this issue Jun 12, 2017 · 1 comment
Open

width() Issue - works with jQuery #1289

cwbeck opened this issue Jun 12, 2017 · 1 comment

Comments

@cwbeck
Copy link

cwbeck commented Jun 12, 2017

There is an issue referencing elements which exist in another frame. If a nested frame is to access the parent window and pass this into the constructor Zepto(topWindow).find(".some-elm") this will correctly return the referenced object, however when .width() is called, it somehow looses scope such that Zepto(topWindow).find(".some-elm").width() is undefined - This is the only breaking change between our jQuery library and Zepto and the only reason we can't swap over.

@cwbeck
Copy link
Author

cwbeck commented Jun 12, 2017

It returns return {top: 0, left: 0} from here...

offset: function(coordinates){

                debugger;

                if (coordinates) return this.each(function(index){
                    var $this = $(this),
                        coords = funcArg(this, coordinates, index, $this.offset()),
                        parentOffset = $this.offsetParent().offset(),
                        props = {
                            top:  coords.top  - parentOffset.top,
                            left: coords.left - parentOffset.left
                        }

                    if ($this.css('position') == 'static') props['position'] = 'relative'
                    $this.css(props)
                })
                if (!this.length) return null
                if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0]))
                    return {top: 0, left: 0}
                var obj = this[0].getBoundingClientRect()
                return {
                    left: obj.left + window.pageXOffset,
                    top: obj.top + window.pageYOffset,
                    width: Math.round(obj.width),
                    height: Math.round(obj.height)
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants