Ticket #930 (closed bug: fixed)
jQuery/Packer/ActiveX Activation
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.2.1 |
| Component: | core | Version: | 1.2 |
| Keywords: | clean flash activex packer | Cc: | |
| Blocking: | Blocked by: |
Description (last modified by john) (diff)
Background
Inserting an ActiveX control (i.e. flash movie, quicktime movie) with an external javascript (i.e. jQuery) should avoid the ugly grey box and having to click to activate.
Bug
ActiveX controls inserted using the packed version of jQuery have the grey box and must be activated. See: jQuery/Packer/ActiveX Bug for more info.
Solution
I've narrowed the problem down to the jQuery.clean method, which uses a temporary div's innerHTML to convert html strings into DOM elements. Doing the conversion from unpacked code fixes the problem, so I'd like to suggest adding a convert hook inside jQuery.clean (see below for patch).
Without the hook, the entire jQuery.clean method has to be overwritten. With the hook, the bug could then be fixed by overwriting jQuery.clean.convert from outside of the packed code (i.e. via a plugin, or by copying and pasting jQuery.clean.convert = function(html) {...} at the bottom of jquery-latest.packed.js).
clean: function(a) {
var r = [];
+ if(!jQuery.clean.convert)
+ jQuery.clean.convert = function(html) {
+ var n = document.createElement('div');
+ div.innerHTML = html;
+ return n;
+ };
jQuery.each( a, function(i,arg){
if ( !arg ) return;
if ( arg.constructor == Number )
arg = arg.toString();
// Convert html string into DOM nodes
if ( typeof arg == "string" ) {
// Trim whitespace, otherwise indexOf won't work as expected
- var s = jQuery.trim(arg), div = document.createElement("div"), tb = [];
+ var s = jQuery.trim(arg), div, tb = [];
var wrap =
// option or optgroup
!s.indexOf("<opt") &&
[1, "<select>", "</select>"] ||
(!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot")) &&
[1, "<table>", "</table>"] ||
!s.indexOf("<tr") &&
[2, "<table><tbody>", "</tbody></table>"] ||
// <thead> matched above
(!s.indexOf("<td") || !s.indexOf("<th")) &&
[3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
[0,"",""];
// Go to html and back, then peel off extra wrappers
- div.innerHTML = wrap[1] + s + wrap[2];
+ div = jQuery.clean.convert(wrap[1] + s + wrap[2]);
// Move to the right depth
while ( wrap[0]-- )
div = div.firstChild;
// Remove IE's autoinserted <tbody> from table fragments
if ( jQuery.browser.msie ) {
// String was a <table>, *may* have spurious <tbody>
if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 )
tb = div.firstChild && div.firstChild.childNodes;
// String was a bare <thead> or <tfoot>
else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
tb = div.childNodes;
for ( var n = tb.length-1; n >= 0 ; --n )
if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
tb[n].parentNode.removeChild(tb[n]);
}
arg = div.childNodes;
}
if ( arg.length === 0 )
return;
if ( arg[0] == undefined )
r.push( arg );
else
r = jQuery.merge( r, arg );
});
return r;
},
Change History
comment:3 Changed 6 years ago by tamlyn
Are there plans to integrate this bug fix into the core? It seems it would only use a very few bytes and would have the benefit of allowing the highly useful flash plugin to run on jquery unpatched.
comment:4 Changed 6 years ago by pixeline
I would like to know if this bug will be solved any time soon, as the jqUploader plugin relies on the nice jquery.flash.js plugin. It would be great, as stated above, not to have to patch jquery core in order for this to run.
thanks !
comment:5 Changed 6 years ago by john
- Status changed from new to closed
- Description modified (diff)
- Version set to 1.2
- Milestone set to 1.2.1
- need set to Review
- Resolution set to fixed
We now provide a minified version of jQuery - you should recommend that your users use that instead (if you want to avoid activation.)
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I think you meant to do: n.innerHTML = html;
instead of: div.innerHTML = html;