html element creation problem

html element creation problem

While creating html elements with jQuery, attributes specified in html prevent attributes specified with parameter.


function test(html, attribs)
{
  var $a;
  if (attribs)
    $a = $(html, attribs);
  else 
    $a = $(html);
  console.log($a[0].outerHTML);
}
test("<div />", { html: "TEST10"});
test("<div />", { text: "TEST11"});

console.log("---------------");

test("<div data-a='x'>TEST20</div>");
test("<div class='x'>TEST21</div>");

console.log("---------------");

test("<div data-a='x'></div>", {text: "TEST30"});
test('<div data-a="x"></div>', {text: "TEST31"});
test('<div class="x"></div>', {text: "TEST32"});

test("<div data-a='x'></div>", {html: "TEST40"});
test('<div data-a="x"></div>', {html: "TEST41"});
test('<div class="x"></div>', {html: "TEST42"});

console.log("---------------");

console.debug($.parseHTML("<div data-a='x'>TEST50</div>")[0].outerHTML);
console.debug($.parseHTML("<div data-a='x'>TEST51</div>")[0].outerHTML);