-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Also stop at root when extracting CSS color #1084
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
Conversation
The Travis CI build failure has nothing to do with this change. It looks like jshint is complaining about |
This change adds an additional check for whether the parent element is `null` or `undefined` in `$.color.extract`. This can happen when working with elements that have not yet been added to the DOM under `<body>`. Consider the following example pie chart. var elm = $("<div />") .css({ width: "240px" , height: "320px" }) var data = [ {label: "One", data: "33"} , {label: "Two", data: "33"} , {label: "Three", data: "33"} ] var opts = { legend: { show: true } , series: { pie: { show: true } } } $.plot(elm, data, opts) elm.appendTo($("body")) When flot inserts each legend row, it tries to use the same color as the corresponding graph part, unless it was explicitly specified in the options. However, in this example, `$.color.extract` runs into an unexpected `null` reference because `<body>` is not an ancestor of `elm`. Specifically, a `TypeError: Cannot read property 'nodeName' of undefined` would be thrown.
Thank you for finding, reporting, and fixing this! |
Also stop at root when extracting CSS color
I was running into this issue as well, thanks! However, I'm not seeing this fix in the main jquery.flot.js file. I don't know if I'm expected to wait until a new (tagged) release of flot that would include these fixes in the jquery.flot.js file (I believe there are tens of commits not included in that file as of today). @dnschnur can you help me on this? |
@quentindemetz When you say 'main' jquery.flot.js, where are you getting that from? The zipfile linked from www.flotcharts.org is still 0.8.1; this will go out (quite soon, hopefully) with 0.8.2. To get the fix grab master. |
I am talking about https://github.com/flot/flot/blob/master/jquery.flot.js. That's the version I am using. Can you confirm? |
Oh, sorry, you are correct. I've been working too much on the 0.9 branch, where this dependency is no longer inlined. Fixed. |
Awesome, thanks a million! |
This change adds an additional check for whether the parent element is
null
orundefined
in$.color.extract
. This can happen when working with elements that have not yet been added to the DOM under<body>
.Consider the following example pie chart.
When flot inserts each legend row, it tries to use the same color as the corresponding graph part, unless it was explicitly specified in the options. However, in this example,
$.color.extract
runs into an unexpectednull
reference because<body>
is not an ancestor ofelm
. Specifically, aTypeError: Cannot read property 'nodeName' of undefined
would be thrown.