Skip to content

Commit a0c9d76

Browse files
author
Matt Mazzola
committed
Rename component 'name' variable to 'type' to avoid conflicts with function.name which is undefined in some browsers but read-only in others causing issues with both not assigning a value or assigning a value.
1 parent 1797cf0 commit a0c9d76

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ export class PowerBi {
100100
private embedNew(element: IPowerBiElement, config: IEmbedOptions): Embed {
101101
const componentType = config.type || element.getAttribute(Embed.typeAttribute);
102102
if (!componentType) {
103-
throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${Embed.typeAttribute}="${Report.name.toLowerCase()}"'.`);
103+
throw new Error(`Attempted to embed using config ${JSON.stringify(config)} on element ${element.outerHTML}, but could not determine what type of component to embed. You must specify a type in the configuration or as an attribute such as '${Embed.typeAttribute}="${Report.type.toLowerCase()}"'.`);
104104
}
105105

106106
// Save type on configuration so it can be referenced later at known location
107107
config.type = componentType;
108108

109-
const Component = Utils.find(component => componentType === component.name.toLowerCase(), PowerBi.components);
109+
const Component = Utils.find(component => componentType === component.type.toLowerCase(), PowerBi.components);
110110
if (!Component) {
111111
throw new Error(`Attempted to embed component of type: ${componentType} but did not find any matching component. Please verify the type you specified is intended.`);
112112
}

src/embed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export abstract class Embed {
4747
* Attribute used to specify type of visual.
4848
* Example: `<div powerbi-type="report"></div>`
4949
*/
50-
public static name: string;
50+
public static type: string;
5151
/**
5252
* Default options for embeddable component.
5353
*/

src/report.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface IReportLoadMessage extends ILoadMessage {
55
}
66

77
export class Report extends Embed {
8-
static name = "Report";
8+
static type = "Report";
99

1010
getEmbedUrl(): string {
1111
let embedUrl = super.getEmbedUrl();

src/tile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface ITileLoadMessage extends ILoadMessage {
55
}
66

77
export class Tile extends Embed {
8-
static name = "Tile";
8+
static type = "Tile";
99

1010
getEmbedUrl(): string {
1111
const embedUrl = super.getEmbedUrl();

0 commit comments

Comments
 (0)