Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 00cc9eb

Browse files
committed
rewrite of JQuery lite implementation, which now better supports selected sets
1 parent ef4bb28 commit 00cc9eb

File tree

7 files changed

+601
-199
lines changed

7 files changed

+601
-199
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<a name="0.9.12"><a/>
22
# <angular/> 0.9.12 thought-implanter (in-progress) #
33

4+
### API
5+
- rewrite of JQuery lite implementation for better supports operations on multiple nodes when
6+
matched by a selector.
7+
48
### Breaking changes
59
- Removed the $init() method after the compilation. The old way of compiling the DOM element was
610
angular.compile(element).$init(); The $init was there to allow the users to do any work to the

src/Angular.js

+8-24
Original file line numberDiff line numberDiff line change
@@ -268,24 +268,6 @@ function extensionMap(angular, name, transform) {
268268
});
269269
}
270270

271-
function jqLiteWrap(element) {
272-
// for some reasons the parentNode of an orphan looks like _null but its typeof is object.
273-
if (element) {
274-
if (isString(element)) {
275-
var div = document.createElement('div');
276-
// Read about the NoScope elements here:
277-
// http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx
278-
div.innerHTML = '<div>&nbsp;</div>' + element; // IE insanity to make NoScope elements work!
279-
div.removeChild(div.firstChild); // remove the superfluous div
280-
element = new JQLite(div.childNodes);
281-
} else if (!(element instanceof JQLite)) {
282-
element = new JQLite(element);
283-
}
284-
}
285-
return element;
286-
}
287-
288-
289271
/**
290272
* @workInProgress
291273
* @ngdoc function
@@ -422,7 +404,9 @@ function isBoolean(value) { return typeof value == $boolean;}
422404
function isTextNode(node) { return nodeName_(node) == '#text'; }
423405
function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; }
424406
function isElement(node) {
425-
return node && (node.nodeName || node instanceof JQLite || (jQuery && node instanceof jQuery));
407+
return node &&
408+
(node.nodeName // we are a direct element
409+
|| (node.bind && node.find)); // we have a bind and find method part of jQuery API
426410
}
427411

428412
/**
@@ -1057,11 +1041,11 @@ function bindJQuery(){
10571041
// bind to jQuery if present;
10581042
jQuery = window.jQuery;
10591043
// reset to jQuery or default to us.
1060-
if (window.jQuery) {
1061-
jqLite = window.jQuery;
1062-
extend(jqLite.fn, {
1063-
scope: JQLite.prototype.scope,
1064-
cloneNode: cloneNode
1044+
if (jQuery) {
1045+
jqLite = jQuery;
1046+
extend(jQuery.fn, {
1047+
scope: JQLitePrototype.scope,
1048+
cloneNode: JQLitePrototype.cloneNode
10651049
});
10661050
} else {
10671051
jqLite = jqLiteWrap;

src/Compiler.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Template.prototype = {
2626
if (!queue) {
2727
inits[this.priority] = queue = [];
2828
}
29-
element = jqLite(element);
3029
if (this.newScope) {
3130
childScope = createScope(scope);
3231
scope.$onEval(childScope.$eval);
@@ -45,7 +44,7 @@ Template.prototype = {
4544
paths = this.paths,
4645
length = paths.length;
4746
for (i = 0; i < length; i++) {
48-
children[i].collectInits(childNodes[paths[i]], inits, childScope);
47+
children[i].collectInits(jqLite(childNodes[paths[i]]), inits, childScope);
4948
}
5049
},
5150

@@ -98,7 +97,7 @@ Compiler.prototype = {
9897
scope = scope || createScope();
9998
element = element === true
10099
? templateElement.cloneNode()
101-
: (jqLite(element) || templateElement);
100+
: (element ? jqLite(element) : templateElement);
102101
element.data($$scope, scope);
103102
template.attach(element, scope);
104103
scope.$element = element;

0 commit comments

Comments
 (0)