Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
justinfagnani committed May 20, 2020
1 parent cef052d commit 0902acb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
8 changes: 4 additions & 4 deletions src/lib/css-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ const textFromCSSResult = (value: CSSResult|number) => {
};

/**
* Template tag which which can be used with LitElement's [[LitElement.styles | `styles`]] property to
* set element styles. For security reasons, only literal string values may be
* used. To incorporate non-literal values [[`unsafeCSS`]] may be used inside a
* template string part.
* Template tag which which can be used with LitElement's [[LitElement.styles |
* `styles`]] property to set element styles. For security reasons, only literal
* string values may be used. To incorporate non-literal values [[`unsafeCSS`]]
* may be used inside a template string part.
*/
export const css =
(strings: TemplateStringsArray, ...values: (CSSResult|number)[]) => {
Expand Down
12 changes: 8 additions & 4 deletions src/lib/updating-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*/

/**
* Use this module if you want to create your own base class extending [[UpdatingElement]].
* Use this module if you want to create your own base class extending
* [[UpdatingElement]].
* @packageDocumentation
*/

Expand Down Expand Up @@ -367,7 +368,8 @@ export abstract class UpdatingElement extends HTMLElement {
const oldValue =
(this as {} as {[key: string]: unknown})[name as string];
(this as {} as {[key: string]: unknown})[key as string] = value;
(this as unknown as UpdatingElement).requestUpdateInternal(name, oldValue, options);
(this as unknown as UpdatingElement)
.requestUpdateInternal(name, oldValue, options);
},
configurable: true,
enumerable: true
Expand Down Expand Up @@ -519,7 +521,8 @@ export abstract class UpdatingElement extends HTMLElement {
*/
protected initialize() {
this._updateState = 0;
this._updatePromise = new Promise((res) => this._enableUpdatingResolver = res);
this._updatePromise =
new Promise((res) => this._enableUpdatingResolver = res);
this._changedProperties = new Map();
this._saveInstanceProperties();
// ensures first update will be caught by an early access of
Expand Down Expand Up @@ -654,7 +657,8 @@ export abstract class UpdatingElement extends HTMLElement {
* `updateComplete` promise. This promise can be overridden and is therefore
* not free to access.
*/
protected requestUpdateInternal(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration) {
protected requestUpdateInternal(
name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration) {
let shouldRequestUpdate = true;
// If we have a property key, perform property update steps.
if (name !== undefined) {
Expand Down
17 changes: 7 additions & 10 deletions src/test/lib/updating-element_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1976,19 +1976,17 @@ suite('UpdatingElement', () => {
});

test('can customize properties to update synchronously', async () => {

interface MyPropertyDeclaration extends PropertyDeclaration {
sync: boolean;
}

@customElement(generateElementName())
class E extends UpdatingElement {

static getPropertyDescriptor(
name: PropertyKey,
key: string|symbol,
options: MyPropertyDeclaration) {
const defaultDescriptor = super.getPropertyDescriptor(name, key, options);
name: PropertyKey, key: string|symbol,
options: MyPropertyDeclaration) {
const defaultDescriptor =
super.getPropertyDescriptor(name, key, options);
const setter = defaultDescriptor.set;
return Object.assign(defaultDescriptor, {
set(this: E, value: unknown) {
Expand Down Expand Up @@ -2021,15 +2019,14 @@ suite('UpdatingElement', () => {
this.updateCount++;
}

@property({type: Number, sync: true, reflect: true} as PropertyDeclaration)
@property(
{type: Number, sync: true, reflect: true} as PropertyDeclaration)
foo = 5;

@property({type: Number, sync: true} as PropertyDeclaration)
zug = this.foo;

@property({})
bar = 'bar';

@property({}) bar = 'bar';
}

const el = new E();
Expand Down
12 changes: 6 additions & 6 deletions src/test/lit-element_styling_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,7 @@ suite('Static get styles', () => {
});

const testAdoptedStyleSheets =
(window.ShadowRoot) &&
('replace' in CSSStyleSheet.prototype);
(window.ShadowRoot) && ('replace' in CSSStyleSheet.prototype);
(testAdoptedStyleSheets ? test : test.skip)(
'Can return CSSStyleSheet where adoptedStyleSheets are natively supported',
async () => {
Expand Down Expand Up @@ -933,7 +932,8 @@ suite('Static get styles', () => {
// When the WC polyfills are included, calling .replaceSync is a noop to
// our styles as they're already flattened (so expect 4px). Otherwise,
// look for the updated value.
const usesAdoptedStyleSheet = (window.ShadyCSS === undefined || window.ShadyCSS.nativeShadow);
const usesAdoptedStyleSheet =
(window.ShadyCSS === undefined || window.ShadyCSS.nativeShadow);
const expectedValue = usesAdoptedStyleSheet ? '2px' : '4px';
sheet.replaceSync('div { border: 2px solid red; }');

Expand All @@ -945,8 +945,7 @@ suite('Static get styles', () => {
// Test that when ShadyCSS is enabled (while still having native support for
// adoptedStyleSheets), we can return a CSSStyleSheet that will be flattened
// and play nice with others.
const testShadyCSSWithAdoptedStyleSheetSupport =
(window.ShadowRoot) &&
const testShadyCSSWithAdoptedStyleSheetSupport = (window.ShadowRoot) &&
('replace' in CSSStyleSheet.prototype) &&
(window.ShadyCSS !== undefined && !window.ShadyCSS.nativeShadow);
(testShadyCSSWithAdoptedStyleSheetSupport ? test : test.skip)(
Expand Down Expand Up @@ -977,7 +976,8 @@ suite('Static get styles', () => {
sheet.replaceSync('div { border: 2px solid red; }');
assert.equal(
getComputedStyle(div).getPropertyValue('border-top-width').trim(),
'4px', 'CSS should not reflect CSSStyleSheet as it was flattened');
'4px',
'CSS should not reflect CSSStyleSheet as it was flattened');
});
});

Expand Down

0 comments on commit 0902acb

Please sign in to comment.