OLD | NEW |
1 <!-- | 1 <!-- |
2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 --> | 5 --> |
6 <import src="observe.sky" as="observe" /> | 6 <import src="observe.sky" as="observe" /> |
7 | 7 |
8 <script> | 8 <script> |
9 Node.prototype.bind = function(name, observable, oneTime) { | 9 Node.prototype.bind = function(name, observable, oneTime) { |
10 var self = this; | 10 var self = this; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 function updateAttribute(el, name, value) { | 50 function updateAttribute(el, name, value) { |
51 el.setAttribute(name, sanitizeValue(value)); | 51 el.setAttribute(name, sanitizeValue(value)); |
52 } | 52 } |
53 | 53 |
54 function attributeBinding(el, name) { | 54 function attributeBinding(el, name) { |
55 return function(value) { | 55 return function(value) { |
56 updateAttribute(el, name, value); | 56 updateAttribute(el, name, value); |
57 }; | 57 }; |
58 } | 58 } |
59 | 59 |
| 60 function bindAsAttribute(el, name) { |
| 61 if (name == 'style' || name == 'class') |
| 62 return true; |
| 63 if (el.tagName == 'a' && name == 'href') |
| 64 return true; |
| 65 } |
| 66 |
60 Element.prototype.bind = function(name, value, oneTime) { | 67 Element.prototype.bind = function(name, value, oneTime) { |
61 if (name !== 'style' && name !== 'class') | 68 if (!bindAsAttribute(this, name)) |
62 return Node.prototype.bind.call(this, name, value, oneTime); | 69 return Node.prototype.bind.call(this, name, value, oneTime); |
63 | 70 |
64 if (oneTime) | 71 if (oneTime) |
65 return updateAttribute(this, name, value); | 72 return updateAttribute(this, name, value); |
66 | 73 |
67 var observable = value; | 74 var observable = value; |
68 updateAttribute(this, name, observable.open(attributeBinding(this, name))); | 75 updateAttribute(this, name, observable.open(attributeBinding(this, name))); |
69 return observable; | 76 return observable; |
70 } | 77 } |
71 | 78 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 121 |
115 var templateAttributeDirectives = { | 122 var templateAttributeDirectives = { |
116 'template': true, | 123 'template': true, |
117 'repeat': true, | 124 'repeat': true, |
118 'bind': true, | 125 'bind': true, |
119 'ref': true | 126 'ref': true |
120 }; | 127 }; |
121 | 128 |
122 function isTemplate(el) { | 129 function isTemplate(el) { |
123 if (el.isTemplate_ === undefined) | 130 if (el.isTemplate_ === undefined) |
124 el.isTemplate_ = el.tagName == 'TEMPLATE'; | 131 el.isTemplate_ = el.tagName == 'template'; |
125 | 132 |
126 return el.isTemplate_; | 133 return el.isTemplate_; |
127 } | 134 } |
128 | 135 |
129 function mixin(to, from) { | 136 function mixin(to, from) { |
130 Object.getOwnPropertyNames(from).forEach(function(name) { | 137 Object.getOwnPropertyNames(from).forEach(function(name) { |
131 Object.defineProperty(to, name, | 138 Object.defineProperty(to, name, |
132 Object.getOwnPropertyDescriptor(from, name)); | 139 Object.getOwnPropertyDescriptor(from, name)); |
133 }); | 140 }); |
134 } | 141 } |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 this.closeInstanceBindings(this.instances[i]); | 1004 this.closeInstanceBindings(this.instances[i]); |
998 } | 1005 } |
999 | 1006 |
1000 this.instances.length = 0; | 1007 this.instances.length = 0; |
1001 this.closeDeps(); | 1008 this.closeDeps(); |
1002 this.templateElement_.iterator_ = undefined; | 1009 this.templateElement_.iterator_ = undefined; |
1003 this.closed = true; | 1010 this.closed = true; |
1004 } | 1011 } |
1005 }; | 1012 }; |
1006 </script> | 1013 </script> |
OLD | NEW |