| OLD | NEW |
| 1 part of angular.directive; | 1 part of angular.directive; |
| 2 | 2 |
| 3 /** | 3 /** |
| 4 * Allows adding and removing the boolean attributes from the element. | 4 * Allows adding and removing the boolean attributes from the element. |
| 5 * | 5 * |
| 6 * Using `<button disabled="{{false}}">` does not work since it would result | 6 * Using `<button disabled="{{false}}">` does not work since it would result |
| 7 * in `<button disabled="false">` rather than `<button>`. | 7 * in `<button disabled="false">` rather than `<button>`. |
| 8 * Browsers change behavior based on presence/absence of attribute rather the | 8 * Browsers change behavior based on presence/absence of attribute rather the |
| 9 * its value. | 9 * its value. |
| 10 * | 10 * |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 @NgDirective(selector: '[ng-srcset]', map: const {'ng-srcset': '@srcset'}) | 66 @NgDirective(selector: '[ng-srcset]', map: const {'ng-srcset': '@srcset'}) |
| 67 class NgSourceDirective { | 67 class NgSourceDirective { |
| 68 NodeAttrs attrs; | 68 NodeAttrs attrs; |
| 69 NgSourceDirective(this.attrs); | 69 NgSourceDirective(this.attrs); |
| 70 | 70 |
| 71 set href(value) => attrs['href'] = value; | 71 set href(value) => attrs['href'] = value; |
| 72 set src(value) => attrs['src'] = value; | 72 set src(value) => attrs['src'] = value; |
| 73 set srcset(value) => attrs['srcset'] = value; | 73 set srcset(value) => attrs['srcset'] = value; |
| 74 | 74 |
| 75 } | 75 } |
| 76 |
| 77 /** |
| 78 * In SVG some attributes have a specific syntax. Placing `{{interpolation}}` in
those |
| 79 * attributes will break the attribute syntax, and browser will clear the attrib
ute. |
| 80 * |
| 81 * The `ng-attr-*` is a generic way to use interpolation without breaking the at
tribute |
| 82 * syntax validator. The `ng-attr-` part get stripped. |
| 83 * |
| 84 * @example |
| 85 <svg> |
| 86 <circle ng-attr-cx="{{cx}}"></circle> |
| 87 </svg> |
| 88 */ |
| 89 @NgDirective(selector: '[ng-attr-*]') |
| 90 class NgAttributeDirective implements NgAttachAware { |
| 91 NodeAttrs _attrs; |
| 92 |
| 93 NgAttributeDirective(NodeAttrs this._attrs); |
| 94 |
| 95 void attach() { |
| 96 _attrs.forEach((key, value) { |
| 97 if (key.startsWith('ngAttr')) { |
| 98 String newKey = snakecase(key.substring(6)); |
| 99 _attrs[newKey] = value; |
| 100 _attrs.observe(snakecase(key), (newValue) => _attrs[newKey] = newValue )
; |
| 101 } |
| 102 }); |
| 103 } |
| 104 } |
| OLD | NEW |