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

fix(core/dfn): treat internal slots as IDL attributes #3646

Merged
merged 23 commits into from
Jun 28, 2021

Conversation

marcoscaceres
Copy link
Contributor

@marcoscaceres marcoscaceres commented Jun 21, 2021

Closes https://github.com/w3c/respec/issues/3644

Require that all internal slots be "for" something.

@marcoscaceres marcoscaceres changed the title fix(core/dfn): treat internal slots as IDL fix(core/dfn): treat internal slots as IDL attributes Jun 21, 2021
src/core/dfn.js Outdated
* @param {string} title
* @param {HTMLElement} dfn
*/
function processInternalSlotsAsIDL(title, dfn) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although webref gives IDL attribute and internal slots the same type: "attribute", an internal slot is not an IDL attribute. So I would rename this to something like associateInternalSlotWithIDL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dontcallmedom
Copy link
Member

to close #3644 ReSpec would also need to flag as error any definition that doesn't match the established taxonomy

@marcoscaceres
Copy link
Contributor Author

to close #3644 ReSpec would also need to flag as error any definition that doesn't match the established taxonomy

Will add... I'll also do automatic checking for [[\method]](that, people, like), and set the type to "method".

Won't export by default.

src/core/dfn.js Outdated
"Use a `data-dfn-for` attribute to associate this dfn with a WebIDL interface.";
showError(msg, name, { hint, elements: [dfn] });
}
dfn.dataset.dfnType = "attribute";
Copy link
Member

@sidvishnoi sidvishnoi Jun 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something that will be fixed in follow-up, right? i.e., a new internalSlot type and internalSlotMethod maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the existing tools throw if we introduce a new dfnType here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re new type, discussion started in speced/spec-dfn-contract#1

@@ -60,8 +60,7 @@ function processAsInternalSlot(title, dfn) {
// Assure that it's data-dfn-for= something.
if (!dfn.dataset.dfnFor) {
const msg = `Internal slot "${title}" must be associated with a WebIDL interface.`;
const hint =
"Use a `data-dfn-for` attribute to associate this dfn with a WebIDL interface.";
const hint = docLink`Use a ${"[data-dfn-for]"} attribute to associate this dfn with a WebIDL interface.`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, interesting!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will eventually need a way to actually verify this... but pretty cool if we can do that!

data-lt="${lt}"
><code>[[${identifier}]]</code></a
><code>[[${identifier}]]${isMethod ? html`(${argsHtml})` : null}</code></a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can probably merge this into argsHtml above.

Comment on lines +190 to +191
const ops = makeStandardOps(null, body);
const doc = await makeRSDoc(ops);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is repeated (with same args) in each test here. Can probably move it into a beforeAll?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's specific to this particular describe() group, so beforeAll is probably not ideal... wish they had a "before you run these tests".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think beforeAll is scoped to desribe() blocks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will try. The docs said they beforeAll was global.

const doc = await makeRSDoc(ops);
const dfn = doc.getElementById("method");
expect(dfn.textContent.trim()).toBe(
"[[I am_a method]](I, really, ...am)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are spaces acceptable in internal slot names? Any real world examples?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are no rules, which is another reason why I'm not very comfortable with labeling them as attributes; there are real-world examples of spaces in internal slots, like [[unique id]] (term.startsWith('[[') && term.match(/ .+\]/) lists them all on https://respec.org/xref/filter/)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I should've checked given I wrote the filter tool 😆)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, at least no internalSlot-method with spaces.

@sidvishnoi sidvishnoi self-requested a review June 23, 2021 11:49
marcoscaceres and others added 4 commits June 23, 2021 23:24
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
@marcoscaceres marcoscaceres merged commit 06eeced into develop Jun 28, 2021
@marcoscaceres marcoscaceres deleted the internal_slot branch June 28, 2021 09:21
rakuco referenced this pull request in rakuco/wake-lock Jun 29, 2021
Specifically, after w3c/respec#3646, we are expected to use
{{Interface[[InternalSlot]]}} rather than just {{[[InternalSlot]]}}.

The changes in this commit are somewhat larger due to the need to keep tidy
happy.
rakuco referenced this pull request in w3c/screen-wake-lock Jun 29, 2021
Specifically, after w3c/respec#3646, we are expected to use
{{Interface[[InternalSlot]]}} rather than just {{[[InternalSlot]]}}.

The changes in this commit are somewhat larger due to the need to keep tidy
happy.
dontcallmedom referenced this pull request in w3c/mediacapture-main Jul 5, 2021
dontcallmedom referenced this pull request in w3c/mediacapture-output Jul 5, 2021
dontcallmedom referenced this pull request in w3c/mediacapture-fromelement Jul 5, 2021
@dontcallmedom
Copy link
Member

Won't export by default.

it looks like this didn't make it in the pull request - i.e. internal slots seems to be exported by default - @marcoscaceres ?

@marcoscaceres
Copy link
Contributor Author

Weird... checking...

@marcoscaceres
Copy link
Contributor Author

Ah, found it... it's following "the contract" (export everything except "dfn")... I'll fix this as part of https://github.com/w3c/respec/pull/3667/

Cc you there!

@marcoscaceres marcoscaceres restored the internal_slot branch July 26, 2021 00:35
@marcoscaceres marcoscaceres deleted the internal_slot branch July 26, 2021 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<dfn data-dfn-type=idl> is incorrectly allowed without error
4 participants