fix(class): allow class names with mixed case
Fixes #3001 BREAKING CHANGE: View renderer used to take normalized CSS class names (ex. fooBar for foo-bar). With this change a rendered implementation gets a calss name as specified in a template, without any transformations / normalization. This change only affects custom view renderers that should be updated accordingly. Closes #3264
This commit is contained in:
@ -23,7 +23,12 @@ import {DomElementBinder, Event, HostAction} from './element_binder';
|
||||
|
||||
import * as api from '../../api';
|
||||
|
||||
import {NG_BINDING_CLASS, EVENT_TARGET_SEPARATOR, queryBoundTextNodeIndices} from '../util';
|
||||
import {
|
||||
NG_BINDING_CLASS,
|
||||
EVENT_TARGET_SEPARATOR,
|
||||
queryBoundTextNodeIndices,
|
||||
camelCaseToDashCase
|
||||
} from '../util';
|
||||
|
||||
export class ProtoViewBuilder {
|
||||
variableBindings: Map<string, string> = new Map();
|
||||
@ -366,7 +371,8 @@ function createElementPropertyBinding(ast: ASTWithSource, propertyNameInTemplate
|
||||
} else if (parts[0] == ATTRIBUTE_PREFIX) {
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.ATTRIBUTE, ast, parts[1]);
|
||||
} else if (parts[0] == CLASS_PREFIX) {
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.CLASS, ast, parts[1]);
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.CLASS, ast,
|
||||
camelCaseToDashCase(parts[1]));
|
||||
} else if (parts[0] == STYLE_PREFIX) {
|
||||
var unit = parts.length > 2 ? parts[2] : null;
|
||||
return new api.ElementPropertyBinding(api.PropertyBindingType.STYLE, ast, parts[1], unit);
|
||||
|
@ -42,11 +42,10 @@ export class DomView {
|
||||
|
||||
setElementClass(elementIndex: number, className: string, isAdd: boolean) {
|
||||
var element = this.boundElements[elementIndex];
|
||||
var dashCasedClassName = camelCaseToDashCase(className);
|
||||
if (isAdd) {
|
||||
DOM.addClass(element, dashCasedClassName);
|
||||
DOM.addClass(element, className);
|
||||
} else {
|
||||
DOM.removeClass(element, dashCasedClassName);
|
||||
DOM.removeClass(element, className);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user