Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
fix(#471): refactoring object references
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Nov 25, 2019
1 parent 9f99e29 commit a83c3cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class DeckdeckgoSlidePoll implements DeckdeckgoSlideResize {
await this.updateChartAnswersData();

if (this.chartData && this.chartData.length >= 1) {
await updateCurrentBar(this.el);
await updateCurrentBar(this.el, this.chartData[0].values);

await this.updatePoll();
}
Expand All @@ -111,7 +111,7 @@ export class DeckdeckgoSlidePoll implements DeckdeckgoSlideResize {
this.oldPollKey = this.pollKey;
this.pollKey = key;

await initHowTo(this.el);
await initHowTo(this.el, this.pollKey);
}
});

Expand Down Expand Up @@ -297,7 +297,7 @@ export class DeckdeckgoSlidePoll implements DeckdeckgoSlideResize {

await drawChart(this.el, this.chartWidth, this.chartHeight);

await initHowTo(this.el);
await initHowTo(this.el, this.pollKey);
}

this.pollConnected.emit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ export function initChartDataBar(el: HTMLElement, answerSlotName: string, index:
});
}

export async function updateCurrentBar(el: HTMLElement) {
export async function updateCurrentBar(el: HTMLElement, values: DeckdeckgoBarChartDataValue[]) {
const element: HTMLElement = el.shadowRoot.querySelector('deckgo-bar-chart');

if (element) {
await (element as any).updateCurrentBar(this.chartData[0].values);
await (element as any).updateCurrentBar(values);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function initHowTo(el: HTMLElement): Promise<void> {
export function initHowTo(el: HTMLElement, pollKey: string): Promise<void> {
return new Promise<void>(async (resolve) => {
const howToSlotElement: HTMLElement = el.querySelector(':scope > [slot=\'how-to\']');

Expand All @@ -20,14 +20,14 @@ export function initHowTo(el: HTMLElement): Promise<void> {
container.removeChild(howTo);
}

const element: HTMLElement = await cloneHowTo(howToSlotElement);
const element: HTMLElement = await cloneHowTo(howToSlotElement, pollKey);
container.appendChild(element);

resolve();
});
}

function cloneHowTo(howToSlotElement: HTMLElement): Promise<HTMLElement> {
function cloneHowTo(howToSlotElement: HTMLElement, pollKey: string): Promise<HTMLElement> {
return new Promise<HTMLElement>((resolve) => {
const element: HTMLElement = howToSlotElement.cloneNode(true) as HTMLElement;
element.removeAttribute('slot');
Expand All @@ -38,7 +38,7 @@ function cloneHowTo(howToSlotElement: HTMLElement): Promise<HTMLElement> {
return;
}

const replaceWith: string = this.pollKey ? this.pollKey.toString().replace(/\B(?=(\d{2})+(?!\d))/g, ' ') : '{0}';
const replaceWith: string = pollKey ? pollKey.toString().replace(/\B(?=(\d{2})+(?!\d))/g, ' ') : '{0}';

element.innerHTML = element.innerHTML.replace(/\{0\}/g, replaceWith);

Expand Down

0 comments on commit a83c3cf

Please sign in to comment.