When farbtastic was converted to use:
(function($) {
}) (jQuery);
a bug was introduced.
The actual starting farbtastic code in drupal 7.x is as follows:
// Farbtastic 1.2
(function($) {
$.farbtastic = function (callback) {
$.farbtastic(this, callback);
return this;
};
....
But the original farbtastic code is as follows:
// Farbtastic 1.2
jQuery.fn.farbtastic = function (callback) {
$.farbtastic(this, callback);
return this;
};
...
So I think the correct code in 7.x would be:
// Farbtastic 1.2
(function($) {
$.fn.farbtastic = function (callback) {
$.farbtastic(this, callback);
return this;
};
....
The way, as an example, Garland uses Farbtastic is not affected by this bug, but affects other use cases.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | update-farbtastic_623292_14.patch | 11.88 KB | mfer |
| #9 | 623292-9.patch | 531 bytes | manfer |
| #7 | 623292.patch | 605 bytes | manfer |
| #3 | farbtastic-623292.patch | 483 bytes | manfer |
Comments
Comment #1
manfer commentedAs an example of when it would fail. The easy way to use farbtastic:
won't work.
Comment #2
damien tournoud commentedMakes sense, can you roll a patch?
Comment #3
manfer commentedHere is the patch.
Comment #4
manfer commentedI would like to make a question because I don't know how the drupal core process works.
The first question is if I named the patch correctly or maybe I should have named it only 623292.patch. In other issues I see the patch is tested with some kind of automatic system. Is that something a normal user can do or something automatically done if the patch name is correct or just something done by drupal developers?
The second is only to know if this won't be forgotten because for me is important to be corrected. Of course, I suppose it is only time needed to proceed with this change because should be lots and lots of things with higher priority.
Anyway I'm going to take the opportunity to present a drupal 7 style example that is going to fail if it is not corrected:
If the farbtastic.js is not corrected this kind of use is going to trigger a javascript error. In the above code example the error will be:
Comment #5
damien tournoud commentedYou need to set the status to "needs review" if you want this patch to be reviewed (both by our test bot and by human reviewer).
The patch looks fine, but you need to roll it from the Drupal root (the test bot will complain that it doesn't apply). Please see http://drupal.org/patch/create for additional instructions.
Comment #7
manfer commentedI hope I have done correctly now. Sorry if I mistake again, it is first time.
Thanks very much to point me to doc.
Comment #9
manfer commentedThe one in #7 was made from netbeans IDE. I thought I was doing it from root but it seems I don't know how to do a correct diff from that IDE.
Sorry, one more try now from terminal and I think it is done from root. I have to finally learn how to do this correctly.
Comment #10
mfer commentedIf you're rolling a patch against farbtastic you might want to roll it against http://code.google.com/p/farbtastic.
Comment #11
manfer commentedThe problem is not present on farbtastic 1.2 original code. I don't see it in farbtastic 1.3 (or 2.0 I have not clear) development you suggest me to look either.
So I can't know when that bug was introduced in the code included with drupal but it is present there not in any farbtastic code.
Including that newer version of farbtastic (1.3 or 2.0 whatever it will be) that conforms to drupal 7:
would solve the issue too.
Comment #12
mfer commented@manfer we need to update to newest code in farbtastic 1.x before we release D7. Farbtastic 1.3 is not released yet so I have been holding off.
Let me see about a farbtastic release. It would be nice to just drop the minified farbtastic 1.3 n D7.
Comment #13
manfer commentedThanks for looking on it.
Anyway now that I looked a little more on farbtastic it won't be a problem for me to change code like this:
to:
or:
and it will work even with that bug present. I'm using farbtastic picker for a very basic use and don't need the farbtastic object nor the farbtastic placeholder after creating it and any of those 3 methods works for me (the first method only with the bug corrected).
It is nice to know it will be fixed. Thanks.
Comment #14
mfer commentedFarbtastic, as it sits in Drupal, starts out:
The first of these should start $.fn.farbtastic so it can be used in chaining.
The attached patch fixes that, updates the code to head from the farbtastic 1 branch at http://code.google.com/p/farbtastic, and uses the minified version (via Google closure compiler which jQuery is now using as well). The uncompressed version can be seen at http://code.google.com/p/farbtastic/source/browse/branches/farbtastic-1/...
This has been tested with jQuery 1.4 as well and it works.
Comment #15
mfer commentedComment #16
robloachApplied patch and Color module worked quite nicely. The testing bot also liked this one so I'm hitting the go button.
Comment #17
robloachLet's use a more appropriate title and apply some tags, shall we?
Comment #18
dries commentedCommitted to CVS HEAD. Thanks.