fix(compiler): keep DOM.hasProperty
in sync between browser and transformer.
Right now, we always return true until we have property schema support (#2014). Fixes #2984 Closes #2981
This commit is contained in:
parent
7ee6963f5d
commit
b3a763a718
@ -98,17 +98,19 @@ final _keyCodeToKeyMap = const {
|
|||||||
class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||||
js.JsFunction _setProperty;
|
js.JsFunction _setProperty;
|
||||||
js.JsFunction _getProperty;
|
js.JsFunction _getProperty;
|
||||||
js.JsFunction _hasProperty;
|
|
||||||
BrowserDomAdapter() {
|
BrowserDomAdapter() {
|
||||||
_setProperty = js.context.callMethod('eval', ['(function(el, prop, value) { el[prop] = value; })']);
|
_setProperty = js.context.callMethod('eval', ['(function(el, prop, value) { if (prop in el) el[prop] = value; })']);
|
||||||
_getProperty = js.context.callMethod('eval', ['(function(el, prop) { return el[prop]; })']);
|
_getProperty = js.context.callMethod('eval', ['(function(el, prop) { return el[prop]; })']);
|
||||||
_hasProperty = js.context.callMethod('eval', ['(function(el, prop) { return prop in el; })']);
|
|
||||||
}
|
}
|
||||||
static void makeCurrent() {
|
static void makeCurrent() {
|
||||||
setRootDomAdapter(new BrowserDomAdapter());
|
setRootDomAdapter(new BrowserDomAdapter());
|
||||||
}
|
}
|
||||||
bool hasProperty(Element element, String name) =>
|
bool hasProperty(Element element, String name) {
|
||||||
_hasProperty.apply([element, name]);
|
// Always return true as the serverside version html_adapter.dart does so.
|
||||||
|
// TODO: change this once we have schema support.
|
||||||
|
// Note: This nees to kept in sync with html_adapter.dart!
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void setProperty(Element element, String name, Object value) =>
|
void setProperty(Element element, String name, Object value) =>
|
||||||
_setProperty.apply([element, name, value]);
|
_setProperty.apply([element, name, value]);
|
||||||
|
@ -11,7 +11,9 @@ class Html5LibDomAdapter implements DomAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasProperty(element, String name) {
|
hasProperty(element, String name) {
|
||||||
// This is needed for serverside compile to generate the right getters/setters...
|
// This is needed for serverside compile to generate the right getters/setters.
|
||||||
|
// TODO: change this once we have property schema support.
|
||||||
|
// Attention: Keep this in sync with browser_adapter.dart!
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,6 +1245,7 @@ export function main() {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (!IS_DARTIUM) {
|
||||||
describe('Missing property bindings', () => {
|
describe('Missing property bindings', () => {
|
||||||
it('should throw on bindings to unknown properties',
|
it('should throw on bindings to unknown properties',
|
||||||
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {
|
||||||
@ -1270,6 +1271,7 @@ export function main() {
|
|||||||
.then((val) => { async.done(); });
|
.then((val) => { async.done(); });
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Disabled until a solution is found, refs:
|
// Disabled until a solution is found, refs:
|
||||||
// - https://github.com/angular/angular/issues/776
|
// - https://github.com/angular/angular/issues/776
|
||||||
|
@ -22,6 +22,7 @@ export function main() {
|
|||||||
var builder;
|
var builder;
|
||||||
beforeEach(() => { builder = new ProtoViewBuilder(el('<div/>'), ViewType.EMBEDDED); });
|
beforeEach(() => { builder = new ProtoViewBuilder(el('<div/>'), ViewType.EMBEDDED); });
|
||||||
|
|
||||||
|
if (!IS_DARTIUM) {
|
||||||
describe('verification of properties', () => {
|
describe('verification of properties', () => {
|
||||||
|
|
||||||
it('should throw for unknown properties', () => {
|
it('should throw for unknown properties', () => {
|
||||||
@ -54,6 +55,7 @@ export function main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
describe('property normalization', () => {
|
describe('property normalization', () => {
|
||||||
it('should normalize "innerHtml" to "innerHTML"', () => {
|
it('should normalize "innerHtml" to "innerHTML"', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user