Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,12 @@ function roleSetter(element, value) {
}
}

// special mapping for cases where attribute name doesn't match property name
var _lazyAttrToProp;

function attrToProp() {
if (!isPresent(_lazyAttrToProp)) {
_lazyAttrToProp = StringMapWrapper.merge({
"inner-html": "innerHTML",
"readonly": "readOnly",
"tabindex": "tabIndex",
}, DOM.attrToPropMap);
}
return _lazyAttrToProp;
}

// tells if an attribute is handled by the ElementBinderBuilder step
export function isSpecialProperty(propName:string) {
return StringWrapper.startsWith(propName, ARIA_PREFIX)
|| StringWrapper.startsWith(propName, CLASS_PREFIX)
|| StringWrapper.startsWith(propName, STYLE_PREFIX)
|| StringMapWrapper.contains(attrToProp(), propName);
|| StringMapWrapper.contains(DOM.attrToPropMap, propName);
}

/**
Expand Down Expand Up @@ -257,7 +243,7 @@ export class ElementBinderBuilder extends CompileStep {
}

_resolvePropertyName(attrName:string) {
var mappedPropName = StringMapWrapper.get(attrToProp(), attrName);
var mappedPropName = StringMapWrapper.get(DOM.attrToPropMap, attrName);
return isPresent(mappedPropName) ? mappedPropName : attrName;
}
}
9 changes: 5 additions & 4 deletions modules/angular2/src/dom/browser_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ class BrowserDomAdapter extends DomAdapter {
setRootDomAdapter(new BrowserDomAdapter());
}

// override JS logic of attribute to property mapping
@override
final attrToPropMap = const {
"inner-html": "innerHtml"
'inner-html': 'innerHtml',
'readonly': 'readOnly',
'tabindex': 'tabIndex',
};

query(String selector) => document.querySelector(selector);
Expand Down Expand Up @@ -108,13 +109,13 @@ class BrowserDomAdapter extends DomAdapter {
createScriptTag(String attrName, String attrValue,
[HtmlDocument doc = null]) {
if (doc == null) doc = document;
var el = doc.createElement("SCRIPT");
var el = doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
}
StyleElement createStyleElement(String css, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
var el = doc.createElement("STYLE");
var el = doc.createElement('STYLE');
el.text = css;
return el;
}
Expand Down
14 changes: 9 additions & 5 deletions modules/angular2/src/dom/browser_adapter.es6
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {isPresent} from 'angular2/src/facade/lang';
import {DomAdapter, setRootDomAdapter} from './dom_adapter';

var EMPTY_MAP = MapWrapper.create();
var _attrToPropMap = {
'inner-html': 'innerHTML',
'readonly': 'readOnly',
'tabindex': 'tabIndex',
};

export class BrowserDomAdapter extends DomAdapter {
static makeCurrent() {
setRootDomAdapter(new BrowserDomAdapter());
}

get attrToPropMap():Map {
return EMPTY_MAP
get attrToPropMap() {
return _attrToPropMap;
}

query(selector) {
Expand Down Expand Up @@ -75,7 +79,7 @@ export class BrowserDomAdapter extends DomAdapter {
return res;
}
clearNodes(el) {
el.innerHTML = "";
el.innerHTML = '';
}
appendChild(el, node) {
el.appendChild(node);
Expand Down Expand Up @@ -133,7 +137,7 @@ export class BrowserDomAdapter extends DomAdapter {
return doc.createTextNode(text);
}
createScriptTag(attrName:string, attrValue:string, doc=document) {
var el = doc.createElement("SCRIPT");
var el = doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
}
Expand Down
8 changes: 7 additions & 1 deletion modules/angular2/src/dom/dom_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ function _abstract() {
*/
@ABSTRACT()
export class DomAdapter {
get attrToPropMap():Map {

/**
* Maps attribute names to their corresponding property names for cases
* where attribute name doesn't match property name.
*/
get attrToPropMap() {
throw _abstract();
}

parse(templateHtml:string) {
throw _abstract();
}
Expand Down