Skip to content

Commit 99ad383

Browse files
committed
Spec: Add HTMLPermissionElement.isTypeSupported static operation.
Specify support for PEPC Feature Detection.
1 parent 559cc4d commit 99ad383

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

permission-element.bs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ time providing implementations with a better signal of user intent.
138138
readonly attribute boolean isValid;
139139
readonly attribute PermissionElementBlockerReason invalidReason;
140140

141+
static boolean isTypeSupported(DOMString type);
142+
141143
attribute EventHandler onpromptaction;
142144
attribute EventHandler onpromptdismiss;
143145
attribute EventHandler onvalidationstatuschange;
@@ -166,6 +168,15 @@ The {{HTMLPermissionElement/invalidReason}} attribute is an
166168
[=enumerated attribute=] that reflects the internal state of the permission
167169
element. It's value set are {{PermissionElementBlockerReason}}
168170

171+
The {{HTMLPermissionElement/isTypeSupported}} [=static operation=] whether a
172+
gives {{HTMLPermissionElement/type}}, that is, a given
173+
[=enumerated attribute|enumeration=] of [=powerful features=], is supported.
174+
It predicts whether creating a <{permission}> element and assigning the given
175+
{{HTMLPermissionElement/type}} string will work, or whether it will create
176+
an element blocked by a {{PermissionElementBlockerReason/type_invalid}}
177+
[=permanent blocker=].
178+
179+
169180
The global <a attribute spec=html for=HTMLElement>lang</a> attribute is
170181
observed by the <{permission}> element to select localized text.
171182

@@ -276,14 +287,37 @@ The HTMLPermissionElement's {{HTMLPermissionElement/type}} setter steps are:
276287

277288
1. If {{[[Types]]}} is not null: Return.
278289
1. Set {{[[Types]]}} to &laquo;[]&raquo;.
279-
1. Parse the input as a string of [=powerful feature=] names, seperated by whitespace.
280-
1. If any errors occured, return.
281-
1. Check if the set of [=powerful features=] is supported for the {{HTMLPermissionElement}} by the [=user agent=]. If not, return.
290+
1. Let |features| be the result of calling [=parse a type string=] with the
291+
input string.
292+
1. If |features| is None, return.
282293
1. [=list/Append=] each [=powerful feature=] name to the {{[[Types]]}} [=ordered set=].
283294

284295
Note: The supported sets of [=powerful features=] is [=implementation-defined=].
285296
</div>
286297

298+
To query whether a feature (or group of features) is supported:
299+
300+
<div algorithm="HTMLPermissionElement/isTypeSupported()">
301+
HTMLPermissionElement's {{HTMLPermissionElement/isTypeSupported()}} method
302+
steps with argument with {{DOMString}} |type|are:
303+
304+
1. Let |features| be the result of calling [=parse a type string=] with |type|.
305+
1. Return whether |features| is not None.
306+
307+
</div>
308+
309+
<div algorithm>
310+
To <dfn>parse a type string</dfn> a given string |type|:
311+
312+
1. Let |list| be the result of parsing |type| as a string of
313+
[=powerful feature=] names, seperated by whitespace.
314+
1. If any errors occured, return None.
315+
1. Check if the set of [=powerful features=] is supported for the
316+
{{HTMLPermissionElement}} by the [=user agent=]. If not, return None.
317+
1. Return |list|.
318+
319+
</div>
320+
287321
### Activation blockers ### {#permission-element-activation-blockers}
288322

289323
The key goal of the <{permission}> element is to reflect a user's conscious

0 commit comments

Comments
 (0)