Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 443b521

Browse files
committed
perf(jqLite): don't check isString many times in constructor
Note: no significant perf gain in Chrome
1 parent e6a9f9e commit 443b521

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/jqLite.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,21 @@ function JQLite(element) {
226226
if (element instanceof JQLite) {
227227
return element;
228228
}
229+
230+
var argIsString;
231+
229232
if (isString(element)) {
230233
element = trim(element);
234+
argIsString = true;
231235
}
232236
if (!(this instanceof JQLite)) {
233-
if (isString(element) && element.charAt(0) != '<') {
237+
if (argIsString && element.charAt(0) != '<') {
234238
throw jqLiteMinErr('nosel', 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element');
235239
}
236240
return new JQLite(element);
237241
}
238242

239-
if (isString(element)) {
243+
if (argIsString) {
240244
jqLiteAddNodes(this, jqLiteParseHTML(element));
241245
} else {
242246
jqLiteAddNodes(this, element);

0 commit comments

Comments
 (0)