Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: third_party/pkg/angular/lib/core_dom/block.dart

Issue 148453003: Updating Angular version (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.core.dom; 1 part of angular.core.dom;
2 2
3 /** 3 /**
4 * ElementWrapper is an interface for [Block]s and [BlockHole]s. Its purpose is 4 * ElementWrapper is an interface for [Block]s and [BlockHole]s. Its purpose is
5 * to allow treating [Block] and [BlockHole] under same interface so that 5 * to allow treating [Block] and [BlockHole] under same interface so that
6 * [Block]s can be added after [BlockHole]. 6 * [Block]s can be added after [BlockHole].
7 */ 7 */
8 abstract class ElementWrapper { 8 abstract class ElementWrapper {
9 List<dom.Node> elements; 9 List<dom.Node> elements;
10 ElementWrapper next; 10 ElementWrapper next;
11 ElementWrapper previous; 11 ElementWrapper previous;
12 } 12 }
13 13
14 /** 14 /**
15 * A Block is a fundamental building block of DOM. It is a chunk of DOM which 15 * A Block is a fundamental building block of DOM. It is a chunk of DOM which
16 * Can not be structural changed. It can only have its attributes changed. 16 * can not be structural changed. It can only have its attributes changed.
17 * A Block can have [BlockHole]s embedded in its DOM. A [BlockHole] can 17 * A Block can have [BlockHole]s embedded in its DOM. A [BlockHole] can
18 * contain other [Block]s and it is the only way in which DOM can be changed 18 * contain other [Block]s and it is the only way in which DOM can be changed
19 * structurally. 19 * structurally.
20 * 20 *
21 * A [Block] is a collection of DOM nodes and [Directive]s for those nodes. 21 * A [Block] is a collection of DOM nodes and [Directive]s for those nodes.
22 * 22 *
23 * A [Block] is responsible for instantiating the [Directive]s and for 23 * A [Block] is responsible for instantiating the [Directive]s and for
24 * inserting / removing itself to/from DOM. 24 * inserting / removing itself to/from DOM.
25 * 25 *
26 * A [Block] can be created from [BlockFactory]. 26 * A [Block] can be created from [BlockFactory].
27 * 27 *
28 */ 28 */
29 class Block implements ElementWrapper { 29 class Block implements ElementWrapper {
30 List<dom.Node> elements; 30 List<dom.Node> elements;
31 ElementWrapper previous = null; 31 ElementWrapper next;
32 ElementWrapper next = null; 32 ElementWrapper previous;
33 33
34 Function onInsert; 34 Function onInsert;
35 Function onRemove; 35 Function onRemove;
36 Function onMove; 36 Function onMove;
37 37
38 List<dynamic> _directives = []; 38 List<dynamic> _directives = [];
39 39
40 Block(this.elements); 40 Block(this.elements);
41 41
42 Block insertAfter(ElementWrapper previousBlock) { 42 Block insertAfter(ElementWrapper previousBlock) {
43 // Update Link List. 43 // Update Link List.
44 next = previousBlock.next; 44 next = previousBlock.next;
45 if (next != null) { 45 if (next != null) {
46 next.previous = this; 46 next.previous = this;
47 } 47 }
48 previous = previousBlock; 48 previous = previousBlock;
49 previousBlock.next = this; 49 previousBlock.next = this;
50 50
51 // Update DOM 51 // Update DOM
52 List<dom.Node> previousElements = previousBlock.elements; 52 List<dom.Node> previousElements = previousBlock.elements;
53 dom.Node previousElement = previousElements[previousElements.length - 1]; 53 dom.Node previousElement = previousElements[previousElements.length - 1];
54 dom.Node insertBeforeElement = previousElement.nextNode; 54 dom.Node insertBeforeElement = previousElement.nextNode;
55 dom.Node parentElement = previousElement.parentNode; 55 dom.Node parentElement = previousElement.parentNode;
56 bool preventDefault = false; 56 bool preventDefault = false;
57 57
58 Function insertDomElements = () { 58 Function insertDomElements = () =>
59 for(var i = 0, ii = elements.length; i < ii; i++) { 59 elements.forEach((el) => parentElement.insertBefore(el, insertBeforeElem ent));
60 parentElement.insertBefore(elements[i], insertBeforeElement);
61 }
62 };
63 60
64 if (onInsert != null) { 61 if (onInsert != null) {
65 onInsert({ 62 onInsert({
66 "preventDefault": () { 63 "preventDefault": () {
67 preventDefault = true; 64 preventDefault = true;
68 return insertDomElements; 65 return insertDomElements;
69 }, 66 },
70 "element": elements[0] 67 "element": elements[0]
71 }); 68 });
72 } 69 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 next.previous = previous; 108 next.previous = previous;
112 } 109 }
113 next = previous = null; 110 next = previous = null;
114 return this; 111 return this;
115 } 112 }
116 113
117 Block moveAfter(ElementWrapper previousBlock) { 114 Block moveAfter(ElementWrapper previousBlock) {
118 var previousElements = previousBlock.elements, 115 var previousElements = previousBlock.elements,
119 previousElement = previousElements[previousElements.length - 1], 116 previousElement = previousElements[previousElements.length - 1],
120 insertBeforeElement = previousElement.nextNode, 117 insertBeforeElement = previousElement.nextNode,
121 parentElement = previousElement.parentNode, 118 parentElement = previousElement.parentNode;
122 blockElements = elements;
123 119
124 for(var i = 0, ii = blockElements.length; i < ii; i++) { 120 elements.forEach((el) => parentElement.insertBefore(el, insertBeforeElement) );
125 parentElement.insertBefore(blockElements[i], insertBeforeElement);
126 }
127 121
128 // Remove block from list 122 // Remove block from list
129 previous.next = next; 123 previous.next = next;
130 if (next != null) { 124 if (next != null) {
131 next.previous = previous; 125 next.previous = previous;
132 } 126 }
133 // Add block to list 127 // Add block to list
134 next = previousBlock.next; 128 next = previousBlock.next;
135 if (next != null) { 129 if (next != null) {
136 next.previous = this; 130 next.previous = this;
137 } 131 }
138 previous = previousBlock; 132 previous = previousBlock;
139 previousBlock.next = this; 133 previousBlock.next = this;
140 return this; 134 return this;
141 } 135 }
142 } 136 }
143 137
144 /** 138 /**
145 * A BlockHole is an instance of a hole. BlockHoles designate where child 139 * A BlockHole is an instance of a hole. BlockHoles designate where child
146 * [Block]s can be added in parent [Block]. BlockHoles wrap a DOM element, 140 * [Block]s can be added in parent [Block]. BlockHoles wrap a DOM element,
147 * and act as references which allows more blocks to be added. 141 * and act as references which allows more blocks to be added.
148 */ 142 */
149
150 class BlockHole extends ElementWrapper { 143 class BlockHole extends ElementWrapper {
151 List<dom.Node> elements; 144 List<dom.Node> elements;
152
153 ElementWrapper previous; 145 ElementWrapper previous;
154
155 ElementWrapper next; 146 ElementWrapper next;
156 147
157 BlockHole(this.elements); 148 BlockHole(this.elements);
158 } 149 }
159 150
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/core/scope.dart ('k') | third_party/pkg/angular/lib/core_dom/block_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698