From 520f1a26845252dd6d7fd5f3b5bb7779ba91eb2c Mon Sep 17 00:00:00 2001 From: John Resig Date: Mon, 7 Sep 2009 20:55:36 +0000 Subject: [PATCH] Broke the logic for .clean() wrap out into a separate, static, data structure. Also improved the performance of .html() looking for the case where .innerHTML can be used without problems. Also tweaked some cases where cleanData() was used, no need to use jQuery selectors in these cases. --- Makefile | 4 +- build.xml | 4 +- src/manipulation.js | 85 ++++++++++++++++++++++----------------- test/unit/manipulation.js | 4 +- 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index c2361205..95e37698 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,12 @@ PLUG_DIR = ../plugins BASE_FILES = ${SRC_DIR}/core.js\ ${SRC_DIR}/data.js\ + ${SRC_DIR}/event.js\ + ${SRC_DIR}/support.js\ ${SRC_DIR}/selector.js\ ${SRC_DIR}/traversing.js\ ${SRC_DIR}/attributes.js\ ${SRC_DIR}/manipulation.js\ - ${SRC_DIR}/event.js\ - ${SRC_DIR}/support.js\ ${SRC_DIR}/css.js\ ${SRC_DIR}/ajax.js\ ${SRC_DIR}/fx.js\ diff --git a/build.xml b/build.xml index 095c52eb..d0ab83c1 100644 --- a/build.xml +++ b/build.xml @@ -54,12 +54,12 @@ + + - - diff --git a/src/manipulation.js b/src/manipulation.js index 30ba5abf..95e2f7ab 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -2,14 +2,32 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rleadingWhitespace = /^\s+/, rxhtmlTag = /(<(\w+)[^>]*?)\/>/g, rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, - rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, + rtagName = /<(\w+)/, rtbody = /"; + }, + wrapMap = { + option: [ 1, "" ], + legend: [ 1, "
", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + col: [ 2, "", "
" ], + _default: [ 0, "", "" ] }; +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and ')); + jQuery("#main").html(valueObj('')); - jQuery("#main").html(valueObj('foo
')); + jQuery("#main").html(valueObj('foo
')); // it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959 jQuery("#main").html(valueObj("