Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
support static attributes
  • Loading branch information
saschanaz committed Apr 14, 2018
commit edf436472c819d706614246dc1ec42bc79e19952
6 changes: 3 additions & 3 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9838,12 +9838,10 @@ interface Notification extends EventTarget {
readonly icon: string;
readonly image: string;
readonly lang: string;
readonly maxActions: number;
onclick: ((this: Notification, ev: Event) => any) | null;
onclose: ((this: Notification, ev: Event) => any) | null;
onerror: ((this: Notification, ev: Event) => any) | null;
onshow: ((this: Notification, ev: Event) => any) | null;
readonly permission: NotificationPermission;
readonly renotify: boolean;
readonly requireInteraction: boolean;
readonly silent: boolean;
Expand All @@ -9861,6 +9859,8 @@ interface Notification extends EventTarget {
declare var Notification: {
prototype: Notification;
new(title: string, options?: NotificationOptions): Notification;
readonly maxActions: number;
readonly permission: NotificationPermission;
requestPermission(deprecatedCallback?: NotificationPermissionCallback): Promise<NotificationPermission>;
};

Expand Down Expand Up @@ -10471,7 +10471,6 @@ interface PromiseRejectionEventInit extends EventInit {
}

interface PushManager {
readonly supportedContentEncodings: ReadonlyArray<string>;
getSubscription(): Promise<PushSubscription | null>;
permissionState(options?: PushSubscriptionOptionsInit): Promise<PushPermissionState>;
subscribe(options?: PushSubscriptionOptionsInit): Promise<PushSubscription>;
Expand All @@ -10480,6 +10479,7 @@ interface PushManager {
declare var PushManager: {
prototype: PushManager;
new(): PushManager;
readonly supportedContentEncodings: ReadonlyArray<string>;
};

interface PushSubscription {
Expand Down
6 changes: 3 additions & 3 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,12 +1017,10 @@ interface Notification extends EventTarget {
readonly icon: string;
readonly image: string;
readonly lang: string;
readonly maxActions: number;
onclick: ((this: Notification, ev: Event) => any) | null;
onclose: ((this: Notification, ev: Event) => any) | null;
onerror: ((this: Notification, ev: Event) => any) | null;
onshow: ((this: Notification, ev: Event) => any) | null;
readonly permission: NotificationPermission;
readonly renotify: boolean;
readonly requireInteraction: boolean;
readonly silent: boolean;
Expand All @@ -1040,6 +1038,8 @@ interface Notification extends EventTarget {
declare var Notification: {
prototype: Notification;
new(title: string, options?: NotificationOptions): Notification;
readonly maxActions: number;
readonly permission: NotificationPermission;
requestPermission(deprecatedCallback?: NotificationPermissionCallback): Promise<NotificationPermission>;
};

Expand Down Expand Up @@ -1218,7 +1218,6 @@ declare var PushEvent: {
};

interface PushManager {
readonly supportedContentEncodings: ReadonlyArray<string>;
getSubscription(): Promise<PushSubscription | null>;
permissionState(options?: PushSubscriptionOptionsInit): Promise<PushPermissionState>;
subscribe(options?: PushSubscriptionOptionsInit): Promise<PushSubscription>;
Expand All @@ -1227,6 +1226,7 @@ interface PushManager {
declare var PushManager: {
prototype: PushManager;
new(): PushManager;
readonly supportedContentEncodings: ReadonlyArray<string>;
};

interface PushMessageData {
Expand Down
7 changes: 3 additions & 4 deletions src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const eventTypeMap: Record<string, string> = {

// Used to decide if a member should be emitted given its static property and
// the intended scope level.
function matchScope(scope: EmitScope, x: Browser.Method) {
function matchScope(scope: EmitScope, x: { static?: 1 | undefined }) {
return scope === EmitScope.All || (scope === EmitScope.StaticOnly) === !!x.static;
}

Expand Down Expand Up @@ -618,10 +618,9 @@ export function emitWebIDl(webidl: Browser.WebIdl, flavor: Flavor) {
}

function emitProperties(prefix: string, emitScope: EmitScope, i: Browser.Interface, conflictedMembers: Set<string>) {
// Note: the schema file shows the property doesn't have "static" attribute,
// therefore all properties are emited for the instance type.
if (emitScope !== EmitScope.StaticOnly && i.properties) {
if (i.properties) {
mapToArray(i.properties.property)
.filter(m => matchScope(emitScope, m))
.filter(p => !isCovariantEventHandler(i, p))
.sort(compareName)
.forEach(p => emitProperty(prefix, i, emitScope, p, conflictedMembers));
Expand Down
1 change: 1 addition & 0 deletions src/widlprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function convertAttribute(attribute: webidl2.AttributeMemberType): Browser.Prope
return {
name: attribute.name,
...convertIdlType(attribute.idlType),
static: attribute.static ? 1 : undefined,
"read-only": attribute.readonly ? 1 : undefined,
"event-handler": attribute.idlType.idlType === "EventHandler" ? attribute.name.slice(2) : undefined
}
Expand Down