fix(router): event.defaultPrevented is not reliable (IE11)
This commit is contained in:
parent
5103f080e9
commit
2287938f5a
|
@ -135,6 +135,9 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
MouseEvent createMouseEvent(String eventType) =>
|
||||
new MouseEvent(eventType, canBubble: true);
|
||||
Event createEvent(String eventType) => new Event(eventType, canBubble: true);
|
||||
void preventDefault(Event evt) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
String getInnerHTML(Element el) => el.innerHtml;
|
||||
String getOuterHTML(Element el) => el.outerHtml;
|
||||
void setInnerHTML(Element el, String value) {
|
||||
|
|
|
@ -77,6 +77,10 @@ createMouseEvent(eventType: string): MouseEvent {
|
|||
createEvent(eventType): Event {
|
||||
return new Event(eventType, true);
|
||||
}
|
||||
preventDefault(evt: Event) {
|
||||
evt.preventDefault();
|
||||
evt.returnValue = false;
|
||||
}
|
||||
getInnerHTML(el) {
|
||||
return el.innerHTML;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ export class DomAdapter {
|
|||
dispatchEvent(el, evt) { throw _abstract(); }
|
||||
createMouseEvent(eventType): any { throw _abstract(); }
|
||||
createEvent(eventType: string): any { throw _abstract(); }
|
||||
preventDefault(evt) { throw _abstract(); }
|
||||
getInnerHTML(el): string { throw _abstract(); }
|
||||
getOuterHTML(el): string { throw _abstract(); }
|
||||
nodeName(node): string { throw _abstract(); }
|
||||
|
|
|
@ -76,6 +76,9 @@ class Html5LibDomAdapter implements DomAdapter {
|
|||
createEvent(eventType) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
preventDefault(evt) {
|
||||
throw 'not implemented';
|
||||
}
|
||||
getInnerHTML(el) {
|
||||
return el.innerHtml;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,9 @@ export class Parse5DomAdapter extends DomAdapter {
|
|||
};
|
||||
return evt;
|
||||
}
|
||||
preventDefault(evt) {
|
||||
evt.returnValue = false;
|
||||
}
|
||||
getInnerHTML(el) {
|
||||
return serializer.serialize(this.templateAwareRoot(el));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export class RouterLink {
|
|||
this._location = location;
|
||||
this._params = StringMapWrapper.create();
|
||||
DOM.on(this._domEl, 'click', (evt) => {
|
||||
evt.preventDefault();
|
||||
DOM.preventDefault(evt);
|
||||
this._router.navigate(this._navigationHref);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ export function main() {
|
|||
view.detectChanges();
|
||||
|
||||
var dispatchedEvent = clickOnElement(view);
|
||||
expect(dispatchedEvent.defaultPrevented).toBe(true);
|
||||
expect(dispatchedEvent.defaultPrevented || !dispatchedEvent.returnValue).toBe(true);
|
||||
|
||||
// router navigation is async.
|
||||
rtr.subscribe((_) => {
|
||||
|
@ -244,7 +244,7 @@ export function main() {
|
|||
view.detectChanges();
|
||||
|
||||
var dispatchedEvent = clickOnElement(view);
|
||||
expect(dispatchedEvent.defaultPrevented).toBe(true);
|
||||
expect(dispatchedEvent.defaultPrevented || !dispatchedEvent.returnValue).toBe(true);
|
||||
|
||||
// router navigation is async.
|
||||
rtr.subscribe((_) => {
|
||||
|
|
Loading…
Reference in New Issue