davatron5000/FitVids.js — Issue #20: Invalid HTML for .wrap()
Author: Krinkle
Created: 2011-11-23 23:46:18+00:00
State: open

Hi,

Just a quick report from me. jQuery requires HTML fragments passed to `jQuery()`, `$.fn.html` or `$.fn.append` to be well-formed, `.wrap()` is no different.

Problem line:

```javascript
$this.wrap('

') // [...]
```

These fragments are created using innerHTML which does not allow shorthand[1] syntax (DIV is not a self-closing element). Modern browsers ignore it and silently fix it, however most versions of Internet Explorer do not, hence it currently fails in some cases.

* Documentation: http://api.jquery.com/jQuery/#creating-new-elements
* Summary: When creating stuff by just it's tag, `$('

' )` and `$('')` shortcuts are fine. When creating anything more complex it has to be either a valid well-formed string of HTML like `wrap('

'` or use something like `$('

', { 'class': 'fluid-width-video-wrapper' } )` or `$('

').addClass('fluid-width-video-wrapper');`