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
9 changes: 4 additions & 5 deletions src/lib/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ const standardCustomElement =
export const customElement = (tagName: string) =>
(classOrDescriptor: Constructor<HTMLElement>|ClassDescriptor) =>
(typeof classOrDescriptor === 'function') ?
legacyCustomElement(
tagName, classOrDescriptor as Constructor<HTMLElement>) :
standardCustomElement(tagName, classOrDescriptor as ClassDescriptor);
legacyCustomElement(tagName, classOrDescriptor) :
standardCustomElement(tagName, classOrDescriptor);

const standardProperty =
(options: PropertyDeclaration, element: ClassElement) => {
Expand Down Expand Up @@ -109,7 +108,7 @@ const standardProperty =
// tslint:disable-next-line:no-any decorator
initializer(this: any) {
if (typeof element.initializer === 'function') {
this[element.key] = element.initializer!.call(this);
this[element.key] = element.initializer.call(this);
}
},
finisher(clazz: typeof UpdatingElement) {
Expand All @@ -122,7 +121,7 @@ const standardProperty =
const legacyProperty =
(options: PropertyDeclaration, proto: Object, name: PropertyKey) => {
(proto.constructor as typeof UpdatingElement)
.createProperty(name!, options);
.createProperty(name, options);
};

/**
Expand Down
5 changes: 3 additions & 2 deletions src/lib/updating-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ export abstract class UpdatingElement extends HTMLElement {
Object.defineProperty(this.prototype, name, {
// tslint:disable-next-line:no-any no symbol in index
get(): any {
// tslint:disable-next-line:no-any no symbol in index
return (this as any)[key];
return this[key];
},
set(this: UpdatingElement, value: unknown) {
// tslint:disable-next-line:no-any no symbol in index
Expand Down Expand Up @@ -632,6 +631,8 @@ export abstract class UpdatingElement extends HTMLElement {
typeof (result as PromiseLike<unknown>).then === 'function') {
await result;
}
// TypeScript can't tell that we've initialized resolve.
// tslint:disable-next-line:no-unnecessary-type-assertion
resolve!(!this._hasRequestedUpdate);
}

Expand Down
8 changes: 4 additions & 4 deletions src/lit-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class LitElement extends UpdatingElement {
return set;
}, new Set<CSSResult>());
// Array.from does not work on Set in IE
styleSet.forEach((v) => styles!.unshift(v));
styleSet.forEach((v) => styles.unshift(v));
} else if (userStyles) {
styles.push(userStyles);
}
Expand Down Expand Up @@ -214,8 +214,8 @@ export class LitElement extends UpdatingElement {
(this.constructor as typeof LitElement)
.render(
templateResult,
this.renderRoot!,
{scopeName: this.localName!, eventContext: this});
this.renderRoot,
{scopeName: this.localName, eventContext: this});
}
// When native Shadow DOM is used but adoptedStyles are not supported,
// insert styling after rendering to ensure adoptedStyles have highest
Expand All @@ -225,7 +225,7 @@ export class LitElement extends UpdatingElement {
(this.constructor as typeof LitElement)._styles!.forEach((s) => {
const style = document.createElement('style');
style.textContent = s.cssText;
this.renderRoot!.appendChild(style);
this.renderRoot.appendChild(style);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/lib/decorators_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ suite('decorators', () => {
const c = new C();
container.appendChild(c);
await c.updateComplete;
const divs = c.divs!;
const divs = c.divs;
// This is not true in ShadyDOM:
// assert.instanceOf(divs, NodeList);
assert.lengthOf(divs, 2);
Expand Down
8 changes: 4 additions & 4 deletions src/test/lit-element_styling_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ suite('Styling', () => {
div = inner!.shadowRoot!.querySelector('div');
assert.equal(
getComputedStyleValue(div!, 'border-top-width').trim(), '2px');
el2!.shadowRoot!.appendChild(inner!);
el2.shadowRoot!.appendChild(inner!);

// Workaround for Safari 9 Promise timing bugs.
await el.updateComplete;
Expand Down Expand Up @@ -307,14 +307,14 @@ suite('Styling', () => {

// Workaround for Safari 9 Promise timing bugs.
await firstApplied.updateComplete && el.updateComplete &&
await (el.applied as I)!.updateComplete;
await (el.applied as I).updateComplete;

await nextFrame();
assert.equal(
getComputedStyleValue(firstApplied!, 'border-top-width').trim(),
getComputedStyleValue(firstApplied, 'border-top-width').trim(),
'2px');
assert.equal(
getComputedStyleValue(firstApplied!, 'margin-top').trim(), '10px');
getComputedStyleValue(firstApplied, 'margin-top').trim(), '10px');
assert.equal(
getComputedStyleValue(el.applied!, 'border-top-width').trim(),
'10px');
Expand Down
1 change: 1 addition & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-var-keyword": true,
"no-unnecessary-type-assertion": true,
"one-line": [
true,
"check-open-brace",
Expand Down