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

Play nicely with browserify #282

Open
EvanCarroll opened this issue Jan 5, 2015 · 3 comments
Open

Play nicely with browserify #282

EvanCarroll opened this issue Jan 5, 2015 · 3 comments

Comments

@EvanCarroll
Copy link

I'm getting

Uncaught TypeError: undefined is not a function

at this block

  Element.addMethods({
    getLayout:              getLayout,
    measure:                measure,
    getWidth:               getWidth,
    getHeight:              getHeight,
    getDimensions:          getDimensions,
    getOffsetParent:        getOffsetParent,
    cumulativeOffset:       cumulativeOffset,
    positionedOffset:       positionedOffset,
    cumulativeScrollOffset: cumulativeScrollOffset,
    viewportOffset:         viewportOffset,
    absolutize:             absolutize,
    relativize:             relativize,
    scrollTo:               scrollTo,
    makePositioned:         makePositioned,
    undoPositioned:         undoPositioned,
    makeClipping:           makeClipping,
    undoClipping:           undoClipping,
    clonePosition:          clonePosition
  });

with Chrome 39. This problem does not exist in 1.7.

@EvanCarroll
Copy link
Author

@jwestbrook
Copy link
Collaborator

I started playing with the code in the gist and was able to make it fail at different places in the object passed to addMethods() and it seems to be related to the Prototype.Browser.Webkit flag that is a feature detection flag that is set higher in the code.

I also re-checked our test suite in Chrome 39 and there was no failures so there is something specific to the browserfiy environment that is causing the error.

I'm still looking into what is causing this

@savetheclocktower
Copy link
Collaborator

The problem seems to be with how browserify treats globals. All of dom.js is wrapped around an anonymous function with one argument, GLOBAL, whose value is this. We presume, then, that this will refer to the global object, be it window or global or whatever one's environment calls it. In that generated browserify file, that this reference no longer points to the global. I don't know enough about browserify to know why.

The result is that this points to an empty object, I think, and when we assign Element to that empty object, it doesn't have implicit global behavior. So that's why the call to Element.addMethods fails in the next closure.

Even after I fix that, we break farther down in the file, because our wrapper around Sizzle is expecting to find it at window.Sizzle. This is an issue that should be fixed in master, though.

@savetheclocktower savetheclocktower changed the title Getting error in 1.7.2 Play nicely with browserify Jan 2, 2016
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

3 participants