Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New method to merge partials and mixins #581

Open
foolip opened this issue Apr 26, 2021 · 4 comments · May be fixed by #584
Open

New method to merge partials and mixins #581

foolip opened this issue Apr 26, 2021 · 4 comments · May be fixed by #584

Comments

@foolip
Copy link
Member

foolip commented Apr 26, 2021

There's code using webidl2.js to parse IDL snippets and then applying partials/mixins in at least 3 different places:

None of them are entirely correct in the handling of [Exposed] and updating them individually is a nuisance.

How about a compile(ast), merge(ast), or simplify(ast) method that folds in partials and mixins as part of webidl2.js?

@dontcallmedom
Copy link
Member

Add WebIDLpedia to that list - so big +1 :)

@saschanaz
Copy link
Member

merge() sound like a good choice as that's what it would do 😀

@foolip
Copy link
Member Author

foolip commented Apr 26, 2021

Trying to handle [Exposed] correctly quickly runs into a problem. When mixins are included into multiple interfaces, the resulting exposure set of the mixin members could be different on the different interfaces. (It's intersected with the host interface's exposure set.) Therefore, a distinct copy of the member will be needed for each interface. Not coincidentally, this matches how Web IDL talks about mixin members:

Each member of M is considered to be a member of each interface I, J, K, … that includes M, as if a copy of each member had been made.

I'm not sure how to copy an instance of Attribute and to change the parent of the copy, if it even matters what this.parent is. One idea inspired by autoParenter is to use a Proxy, but if the proxy is what change the apparent extended attributes, the underlying write() would still get it wrong.

Ideas?

@saschanaz
Copy link
Member

Hmm, so there should be a way to copy a member. For now this kinda works:

// given that we have `attr` of type Attribute
const clone = new attr.constructor({ source: attr.source, tokens: attr.tokens });
Object.assign(clone, attr);

foolip added a commit to foolip/webidl2.js that referenced this issue Apr 27, 2021
@foolip foolip linked a pull request Apr 27, 2021 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants