Use insertAdjacentHTML in domManip for common cases. #1095

wants to merge 1 commit into


None yet

3 participants

jQuery Foundation member

This is my dog-walk thought for the day, passing all unit tests. It would be nice to get .before() and .after() in this path as well but those require a parent node check.

When this path can be taken, it should be incredibly fast since it doesn't need to go through the rest of .domManip() or .clean(). Needs a jsperf as proof.

jQuery Foundation member

cc @orkel

jQuery Foundation member

I didn't want to address #10426 and #10515 in reduction of manipulation module, so it can be easy to digest...

Considerable speedup, it also would be relative easy to add support for before and after just like it would be easy to add support for all array elements in args argument if they all strings, without compromising speed or size too much.

But unfortunately, insertAdjacentHTML is not all good.

passing all unit tests

I suppose, you did not run manipulation tests in IE9? Some of them are failing and there is some cases that jQuery tests do not catch, like –

$("table tr").append("<td/>");

Did you set your mind to fix this ticket in 2.0?

jQuery Foundation member

@orkel, I agree it's better to wait until we land all the existing 2.0 reductions first, there's no hurry. This was just a quick implementation for a proof of concept. Thanks for creating the jsperf! I thought I had it working on IE9 but perhaps I missed a few or did a run with a cached file. If you're going to tackle these I can close this pull request.

The cases like .append("<td/>") would normally be caught in .clean(), we could fix it with a RegExp although it seems like a shame to do that because the string could be very long (such as appending a new view in an MVC framework). Even looking through the string for "<script is a shame but I suppose it's a lot faster than the default path still.

@dmethvin dmethvin closed this Dec 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment