Play nicely with browserify #282
Copy link
Copy link
Open
Labels
Description
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.
Reactions are currently unavailable
Activity
EvanCarroll commentedon Jan 5, 2015
Find the code here. https://gist.github.com/EvanCarroll/073ff45151a397dabb57
jwestbrook commentedon Jan 6, 2015
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 thePrototype.Browser.Webkitflag 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 commentedon Jan 7, 2015
The problem seems to be with how browserify treats globals. All of
dom.jsis wrapped around an anonymous function with one argument,GLOBAL, whose value isthis. We presume, then, thatthiswill refer to the global object, be itwindoworglobalor whatever one's environment calls it. In that generated browserify file, thatthisreference no longer points to the global. I don't know enough about browserify to know why.The result is that
thispoints to an empty object, I think, and when we assignElementto that empty object, it doesn't have implicit global behavior. So that's why the call toElement.addMethodsfails 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.[-]Getting error in 1.7.2[/-][+]Play nicely with browserify[/+]