chore(): fix host properties for MD components.

This commit is contained in:
Jeremy Elbourn
2015-04-23 13:15:20 -07:00
committed by Jeremy Elbourn
parent dff4795e49
commit b9eab463f7
9 changed files with 38 additions and 35 deletions

View File

@ -650,7 +650,7 @@ gulp.task('build', ['build.js', 'build.dart']);
// ------------ // ------------
// angular material testing rules // angular material testing rules
gulp.task('build/css.js.dev', function() { gulp.task('build.js.material', ['build.js.dev'], function() {
return gulp.src('modules/*/src/**/*.scss') return gulp.src('modules/*/src/**/*.scss')
.pipe(sass()) .pipe(sass())
.pipe(autoprefixer()) .pipe(autoprefixer())
@ -658,15 +658,13 @@ gulp.task('build/css.js.dev', function() {
}); });
// TODO: this target is temporary until we find a way to use the SASS transformer // TODO: this target is temporary until we find a way to use the SASS transformer
gulp.task('build/css.dart', function() { gulp.task('build.dart.material', ['build/packages.dart'], function() {
return gulp.src('dist/dart/angular2_material/lib/src/**/*.scss') return gulp.src('dist/dart/angular2_material/src/**/*.scss')
.pipe(sass()) .pipe(sass())
.pipe(autoprefixer()) .pipe(autoprefixer())
.pipe(gulp.dest('dist/dart/angular2_material/lib/src')); .pipe(gulp.dest('dist/dart/angular2_material/lib/src'));
}); });
gulp.task('build.material', ['build.js.dev', 'build/css.js.dev']);
gulp.task('cleanup.builder', function() { gulp.task('cleanup.builder', function() {
angularBuilder.cleanup(); angularBuilder.cleanup();

View File

@ -2,7 +2,7 @@
* Dart version of browser APIs. This library depends on 'dart:html' and * Dart version of browser APIs. This library depends on 'dart:html' and
* therefore can only run in the browser. * therefore can only run in the browser.
*/ */
library angular2.src.facade.browser; library angular2.src.facade.browser;
import 'dart:js' show context; import 'dart:js' show context;
@ -12,6 +12,7 @@ export 'dart:html' show
window, window,
Element, Element,
Node, Node,
MouseEvent,
KeyboardEvent, KeyboardEvent,
Event; Event;

View File

@ -8,3 +8,6 @@ export {win as window};
export var document = window.document; export var document = window.document;
export var location = window.location; export var location = window.location;
export var gc = window.gc ? () => window.gc() : () => null; export var gc = window.gc ? () => window.gc() : () => null;
export {Event as Event};
export {MouseEvent as MouseEvent};
export {KeyboardEvent as KeyboardEvent};

View File

@ -12,3 +12,6 @@ export {win as window};
export var document = window.document; export var document = window.document;
export var location = window.location; export var location = window.location;
export var gc = window.gc ? () => window.gc() : () => null; export var gc = window.gc ? () => window.gc() : () => null;
export const Event = Event;
export const MouseEvent = MouseEvent;
export const KeyboardEvent = KeyboardEvent;

View File

@ -2,6 +2,7 @@ import {Component, View, Attribute} from 'angular2/angular2';
import {isPresent} from 'angular2/src/facade/lang'; import {isPresent} from 'angular2/src/facade/lang';
import {KEY_SPACE} from 'angular2_material/src/core/constants' import {KEY_SPACE} from 'angular2_material/src/core/constants'
import {KeyboardEvent} from 'angular2/src/facade/browser'; import {KeyboardEvent} from 'angular2/src/facade/browser';
import {NumberWrapper} from 'angular2/src/facade/lang';
@Component({ @Component({
selector: 'md-checkbox', selector: 'md-checkbox',
@ -34,12 +35,12 @@ export class MdCheckbox {
role: string; role: string;
/** Setter for tabindex */ /** Setter for tabindex */
tabindex: any; tabindex: number;
constructor(@Attribute('tabindex') tabindex: string) { constructor(@Attribute('tabindex') tabindex: string) {
this.role = 'checkbox'; this.role = 'checkbox';
this.checked = false; this.checked = false;
this.tabindex = isPresent(tabindex) ? tabindex : '0'; this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
} }
get disabled() { get disabled() {

View File

@ -13,7 +13,7 @@ import {Math} from 'angular2/src/facade/math';
'role': 'attr.role', 'role': 'attr.role',
'ariaValuemin': 'attr.aria-valuemin', 'ariaValuemin': 'attr.aria-valuemin',
'ariaValuemax': 'attr.aria-valuemax', 'ariaValuemax': 'attr.aria-valuemax',
'ariaValuenow': 'attr.aria-valuenow' 'value': 'attr.aria-valuenow'
} }
}) })
@View({ @View({
@ -30,23 +30,17 @@ export class MdProgressLinear {
/** The render mode for the progress bar. */ /** The render mode for the progress bar. */
mode: string; mode: string;
/** Attribute setter for aria-valuenow. */
ariaValueNowSetter: Function;
/** CSS `transform` property applied to the primary bar. */ /** CSS `transform` property applied to the primary bar. */
primaryBarTransform: string; primaryBarTransform: string;
/** CSS `transform` property applied to the secondary bar. */ /** CSS `transform` property applied to the secondary bar. */
secondaryBarTransform: string; secondaryBarTransform: string;
role: string;
role:any; ariaValuemin: string;
ariaValuemin:any; ariaValuemax: string;
ariaValuemax:any;
ariaValuenow:any;
constructor(@Attribute('md-mode') mode: string) { constructor(@Attribute('md-mode') mode: string) {
this.ariaValueNowSetter = ariaValueNowSetter;
this.primaryBarTransform = ''; this.primaryBarTransform = '';
this.secondaryBarTransform = ''; this.secondaryBarTransform = '';
@ -64,7 +58,6 @@ export class MdProgressLinear {
set value(v) { set value(v) {
if (isPresent(v)) { if (isPresent(v)) {
this.value_ = MdProgressLinear.clamp(v); this.value_ = MdProgressLinear.clamp(v);
this.ariaValueNowSetter(this.value_);
} }
} }

View File

@ -2,7 +2,7 @@ import {Component, View, Parent, Ancestor, Attribute} from 'angular2/angular2';
import {Optional} from 'angular2/src/di/annotations'; import {Optional} from 'angular2/src/di/annotations';
import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher' import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher'
import {onChange} from 'angular2/src/core/annotations/annotations'; import {onChange} from 'angular2/src/core/annotations/annotations';
import {isPresent, StringWrapper} from 'angular2/src/facade/lang'; import {isPresent, StringWrapper, NumberWrapper} from 'angular2/src/facade/lang';
import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async'; import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection'; import {ListWrapper} from 'angular2/src/facade/collection';
import {KEY_UP, KEY_DOWN, KEY_SPACE} from 'angular2_material/src/core/constants' import {KEY_UP, KEY_DOWN, KEY_SPACE} from 'angular2_material/src/core/constants'
@ -69,9 +69,9 @@ export class MdRadioButton {
/** Dispatcher for coordinating radio unique-selection by name. */ /** Dispatcher for coordinating radio unique-selection by name. */
radioDispatcher: MdRadioDispatcher; radioDispatcher: MdRadioDispatcher;
tabindex:any; tabindex: number;
role:any; role: string;
constructor( constructor(
@Optional() @Parent() radioGroup: MdRadioGroup, @Optional() @Parent() radioGroup: MdRadioGroup,
@ -105,7 +105,9 @@ export class MdRadioButton {
// If the user has not set a tabindex, default to zero (in the normal document flow). // If the user has not set a tabindex, default to zero (in the normal document flow).
if (!isPresent(radioGroup)) { if (!isPresent(radioGroup)) {
this.tabindex = isPresent(tabindex) ? tabindex : '0'; this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
} else {
this.tabindex = -1;
} }
} }
@ -169,12 +171,12 @@ export class MdRadioButton {
'value': 'value' 'value': 'value'
}, },
hostListeners: { hostListeners: {
'keydown': 'onKeydown($event)' // TODO(jelbourn): Remove ^ when event retargeting is fixed.
'^keydown': 'onKeydown($event)'
}, },
hostProperties: { hostProperties: {
'tabindex': 'tabindex', 'tabindex': 'tabindex',
'role': 'attr.role', 'role': 'attr.role',
'checked': 'attr.aria-checked',
'disabled': 'attr.aria-disabled', 'disabled': 'attr.aria-disabled',
'activedescendant': 'attr.aria-activedescendant' 'activedescendant': 'attr.aria-activedescendant'
} }
@ -202,11 +204,11 @@ export class MdRadioGroup {
/** The ID of the selected radio button. */ /** The ID of the selected radio button. */
selectedRadioId: string; selectedRadioId: string;
change:EventEmitter; change: EventEmitter;
tabindex:any; tabindex: number;
role:any; role: string;
constructor( constructor(
@Attribute('tabindex') tabindex: string, @Attribute('tabindex') tabindex: string,
@ -225,7 +227,7 @@ export class MdRadioGroup {
this.disabled = isPresent(disabled); this.disabled = isPresent(disabled);
// If the user has not set a tabindex, default to zero (in the normal document flow). // If the user has not set a tabindex, default to zero (in the normal document flow).
this.tabindex = isPresent(tabindex) ? tabindex : '0'; this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
} }
/** Gets the name of this group, as to be applied in the HTML 'name' attribute. */ /** Gets the name of this group, as to be applied in the HTML 'name' attribute. */
@ -319,6 +321,7 @@ export class MdRadioGroup {
this.radioDispatcher.notify(this.name_); this.radioDispatcher.notify(this.name_);
radio.checked = true; radio.checked = true;
ObservableWrapper.callNext(this.change, null);
this.value = radio.value; this.value = radio.value;
this.selectedRadioId = radio.id; this.selectedRadioId = radio.id;

View File

@ -2,6 +2,7 @@ import {Component, View, Attribute} from 'angular2/angular2';
import {isPresent} from 'angular2/src/facade/lang'; import {isPresent} from 'angular2/src/facade/lang';
import {KEY_SPACE} from 'angular2_material/src/core/constants' import {KEY_SPACE} from 'angular2_material/src/core/constants'
import {KeyboardEvent} from 'angular2/src/facade/browser'; import {KeyboardEvent} from 'angular2/src/facade/browser';
import {NumberWrapper} from 'angular2/src/facade/lang';
// TODO(jelbourn): without gesture support, this is identical to MdCheckbox. // TODO(jelbourn): without gesture support, this is identical to MdCheckbox.
@ -31,13 +32,13 @@ export class MdSwitch {
/** Whether this switch is disabled. */ /** Whether this switch is disabled. */
disabled_: boolean; disabled_: boolean;
tabindex:any; tabindex: number;
role:any; role: string;
constructor(@Attribute('tabindex') tabindex: string) { constructor(@Attribute('tabindex') tabindex: string) {
this.role = 'checkbox'; this.role = 'checkbox';
this.checked = false; this.checked = false;
this.tabindex = isPresent(tabindex) ? tabindex : '0'; this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
} }
get disabled() { get disabled() {

View File

@ -13,13 +13,13 @@ export function commonDemoSetup(): void {
} }
@Injectable() @Injectable()
@IMPLEMENTS(UrlResolver) export class DemoUrlResolver extends UrlResolver {
export class DemoUrlResolver {
static a; static a;
isInPubServe:boolean; isInPubServe:boolean;
constructor() { constructor() {
super();
if (isBlank(UrlResolver.a)) { if (isBlank(UrlResolver.a)) {
UrlResolver.a = DOM.createElement('a'); UrlResolver.a = DOM.createElement('a');
} }