-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Conversation
src/core/dfn.js
Outdated
* @param {string} title | ||
* @param {HTMLElement} dfn | ||
*/ | ||
function processInternalSlotsAsIDL(title, dfn) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see also my remark at https://github.com/w3c/respec/issues/3644#issuecomment-864894696
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 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"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.. See, for example:
https://respec.org/xref/?term=%5B%5BCollectFromCredentialStore%5D%5D%28origin%2C+options%2C+sameOriginWithAncestors%29
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, interesting!
There was a problem hiding this comment.
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!
src/core/inline-idl-parser.js
Outdated
data-lt="${lt}" | ||
><code>[[${identifier}]]</code></a | ||
><code>[[${identifier}]]${isMethod ? html`(${argsHtml})` : null}</code></a |
There was a problem hiding this comment.
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.
const ops = makeStandardOps(null, body); | ||
const doc = await makeRSDoc(ops); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/)
There was a problem hiding this comment.
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 😆)
There was a problem hiding this comment.
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.
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>
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.
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.
As required by new respec release see also https://github.com/w3c/respec/pull/3646
As now required by ReSpec per https://github.com/w3c/respec/pull/3646
As now required by ReSpec per https://github.com/w3c/respec/pull/3646
As now required in ReSpec, per https://github.com/w3c/respec/pull/3646
As now required in ReSpec, per https://github.com/w3c/respec/pull/3646
it looks like this didn't make it in the pull request - i.e. internal slots seems to be exported by default - @marcoscaceres ? |
Weird... checking... |
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! |
Closes https://github.com/w3c/respec/issues/3644
Require that all internal slots be "for" something.