1 | <!doctype html>
|
---|
2 | <head><meta charset="utf-8">
|
---|
3 | <title>Metadata Proposal - ECMAScript</title>
|
---|
4 | <link rel="stylesheet" href="ecmarkup.css">
|
---|
5 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
---|
6 | <script src="ecmarkup.js"></script>
|
---|
7 | <script>
|
---|
8 | if (location.hostname === 'rbuckton.github.io' && location.protocol !== 'https:') {
|
---|
9 | location.protocol = 'https:';
|
---|
10 | }
|
---|
11 | </script>
|
---|
12 | <script type="application/json" id="menu-search-biblio">[{"type":"clause","id":"introduction","aoid":null,"title":"Metadata Proposal - ECMAScript","titleHTML":"Metadata Proposal - ECMAScript","number":"","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Metadata Proposal - ECMAScript"},{"type":"clause","id":"syntax","aoid":null,"title":"Syntax","titleHTML":"Syntax","number":"1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Syntax"},{"type":"op","aoid":"GetOrCreateMetadataMap","refId":"getorcreatemetadatamap","location":"","referencingIds":[],"key":"GetOrCreateMetadataMap"},{"type":"clause","id":"getorcreatemetadatamap","aoid":"GetOrCreateMetadataMap","title":"GetOrCreateMetadataMap ( O, P, Create )","titleHTML":"GetOrCreateMetadataMap ( O, P, Create )","number":"2.1.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_8","_ref_17","_ref_22","_ref_42","_ref_52"],"key":"GetOrCreateMetadataMap ( O, P, Create )"},{"type":"clause","id":"operations-on-objects","aoid":null,"title":"Operations on Objects","titleHTML":"Operations on Objects","number":"2.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Operations on Objects"},{"type":"clause","id":"abstract-operations","aoid":null,"title":"Abstract Operations","titleHTML":"Abstract Operations","number":"2","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Abstract Operations"},{"type":"op","aoid":"OrdinaryHasMetadata","refId":"ordinaryhasmetadata","location":"","referencingIds":[],"key":"OrdinaryHasMetadata"},{"type":"clause","id":"ordinaryhasmetadata","aoid":"OrdinaryHasMetadata","title":"OrdinaryHasMetadata ( MetadataKey, O, P )","titleHTML":"OrdinaryHasMetadata ( MetadataKey, O, P )","number":"3.1.1.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_3"],"key":"OrdinaryHasMetadata ( MetadataKey, O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-hasmetadata","aoid":null,"title":"[[HasMetadata]] ( MetadataKey, P )","titleHTML":"[[HasMetadata]] ( MetadataKey, P )","number":"3.1.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[HasMetadata]] ( MetadataKey, P )"},{"type":"op","aoid":"OrdinaryHasOwnMetadata","refId":"ordinaryhasownmetadata","location":"","referencingIds":[],"key":"OrdinaryHasOwnMetadata"},{"type":"clause","id":"ordinaryhasownmetadata","aoid":"OrdinaryHasOwnMetadata","title":"OrdinaryHasOwnMetadata ( MetadataKey, O, P )","titleHTML":"OrdinaryHasOwnMetadata ( MetadataKey, O, P )","number":"3.1.2.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_5","_ref_6","_ref_13"],"key":"OrdinaryHasOwnMetadata ( MetadataKey, O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-hasownmetadata","aoid":null,"title":"[[HasOwnMetadata]] ( MetadataKey, P )","titleHTML":"[[HasOwnMetadata]] ( MetadataKey, P )","number":"3.1.2","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[HasOwnMetadata]] ( MetadataKey, P )"},{"type":"op","aoid":"OrdinaryGetMetadata","refId":"ordinarygetmetadata","location":"","referencingIds":[],"key":"OrdinaryGetMetadata"},{"type":"clause","id":"ordinarygetmetadata","aoid":"OrdinaryGetMetadata","title":"OrdinaryGetMetadata ( MetadataKey, O, P )","titleHTML":"OrdinaryGetMetadata ( MetadataKey, O, P )","number":"3.1.3.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_11"],"key":"OrdinaryGetMetadata ( MetadataKey, O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-getmetadata","aoid":null,"title":"[[GetMetadata]] ( MetadataKey, P )","titleHTML":"[[GetMetadata]] ( MetadataKey, P )","number":"3.1.3","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[GetMetadata]] ( MetadataKey, P )"},{"type":"op","aoid":"OrdinaryGetOwnMetadata","refId":"ordinarygetownmetadata","location":"","referencingIds":[],"key":"OrdinaryGetOwnMetadata"},{"type":"clause","id":"ordinarygetownmetadata","aoid":"OrdinaryGetOwnMetadata","title":"OrdinaryGetOwnMetadata ( MetadataKey, O, P )","titleHTML":"OrdinaryGetOwnMetadata ( MetadataKey, O, P )","number":"3.1.4.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_14","_ref_15"],"key":"OrdinaryGetOwnMetadata ( MetadataKey, O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-getownmetadata","aoid":null,"title":"[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )","titleHTML":"[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )","number":"3.1.4","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )"},{"type":"op","aoid":"OrdinaryDefineOwnMetadata","refId":"ordinarydefineownmetadata","location":"","referencingIds":[],"key":"OrdinaryDefineOwnMetadata"},{"type":"clause","id":"ordinarydefineownmetadata","aoid":"OrdinaryDefineOwnMetadata","title":"OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )","titleHTML":"OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )","number":"3.1.5.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_19"],"key":"OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-defineownmetadata","aoid":null,"title":"[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )","titleHTML":"[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )","number":"3.1.5","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )"},{"type":"op","aoid":"OrdinaryMetadataKeys","refId":"ordinarymetadatakeys","location":"","referencingIds":[],"key":"OrdinaryMetadataKeys"},{"type":"clause","id":"ordinarymetadatakeys","aoid":"OrdinaryMetadataKeys","title":"OrdinaryMetadataKeys ( O, P )","titleHTML":"OrdinaryMetadataKeys ( O, P )","number":"3.1.6.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_24"],"key":"OrdinaryMetadataKeys ( O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-metadatakeys","aoid":null,"title":"[[MetadataKeys]] ( P )","titleHTML":"[[MetadataKeys]] ( P )","number":"3.1.6","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[MetadataKeys]] ( P )"},{"type":"op","aoid":"OrdinaryOwnMetadataKeys","refId":"ordinaryownmetadatakeys","location":"","referencingIds":[],"key":"OrdinaryOwnMetadataKeys"},{"type":"clause","id":"ordinaryownmetadatakeys","aoid":"OrdinaryOwnMetadataKeys","title":"OrdinaryOwnMetadataKeys ( O, P )","titleHTML":"OrdinaryOwnMetadataKeys ( O, P )","number":"3.1.7.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":["_ref_26","_ref_39"],"key":"OrdinaryOwnMetadataKeys ( O, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-ownmetadatakeys","aoid":null,"title":"[[OwnMetadataKeys]] ( P )","titleHTML":"[[OwnMetadataKeys]] ( P )","number":"3.1.7","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[OwnMetadataKeys]] ( P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots-deletemetadata","aoid":null,"title":"[[DeleteMetadata]]( MetadataKey, P )","titleHTML":"[[DeleteMetadata]]( MetadataKey, P )","number":"3.1.8","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"[[DeleteMetadata]]( MetadataKey, P )"},{"type":"clause","id":"ordinary-object-internal-methods-and-internal-slots","aoid":null,"title":"Ordinary Object Internal Methods and Internal Slots","titleHTML":"Ordinary Object Internal Methods and Internal Slots","number":"3.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Ordinary Object Internal Methods and Internal Slots"},{"type":"clause","id":"ordinary-and-exotic-objects-behaviors","aoid":null,"title":"Ordinary and Exotic Objects Behaviors","titleHTML":"Ordinary and Exotic Objects Behaviors","number":"3","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Ordinary and Exotic Objects Behaviors"},{"type":"clause","id":"reflect-metadatadecoratorfunctions","aoid":null,"title":"Metadata Decorator Functions","titleHTML":"Metadata Decorator Functions","number":"4.1.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Metadata Decorator Functions"},{"type":"clause","id":"reflect.metadata","aoid":null,"title":"Reflect.metadata ( metadataKey, metadataValue )","titleHTML":"Reflect.metadata ( metadataKey, metadataValue )","number":"4.1.2","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.metadata ( metadataKey, metadataValue )"},{"type":"clause","id":"reflect.definemetadata","aoid":null,"title":"Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )","titleHTML":"Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )","number":"4.1.3","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )"},{"type":"clause","id":"reflect.hasmetadata","aoid":null,"title":"Reflect.hasMetadata ( metadataKey, target [, propertyKey] )","titleHTML":"Reflect.hasMetadata ( metadataKey, target [, propertyKey] )","number":"4.1.4","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.hasMetadata ( metadataKey, target [, propertyKey] )"},{"type":"clause","id":"reflect.hasownmetadata","aoid":null,"title":"Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )","titleHTML":"Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )","number":"4.1.5","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )"},{"type":"clause","id":"reflect.getmetadata","aoid":null,"title":"Reflect.getMetadata ( metadataKey, target [, propertyKey] )","titleHTML":"Reflect.getMetadata ( metadataKey, target [, propertyKey] )","number":"4.1.6","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.getMetadata ( metadataKey, target [, propertyKey] )"},{"type":"clause","id":"reflect.getownmetadata","aoid":null,"title":"Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )","titleHTML":"Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )","number":"4.1.7","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )"},{"type":"clause","id":"reflect.getmetadatakeys","aoid":null,"title":"Reflect.getMetadataKeys ( target [, propertyKey] )","titleHTML":"Reflect.getMetadataKeys ( target [, propertyKey] )","number":"4.1.8","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.getMetadataKeys ( target [, propertyKey] )"},{"type":"clause","id":"reflect.getownmetadatakeys","aoid":null,"title":"Reflect.getOwnMetadataKeys ( target [, propertyKey] )","titleHTML":"Reflect.getOwnMetadataKeys ( target [, propertyKey] )","number":"4.1.9","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.getOwnMetadataKeys ( target [, propertyKey] )"},{"type":"clause","id":"reflect.deletemetadata","aoid":null,"title":"Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )","titleHTML":"Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )","number":"4.1.10","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )"},{"type":"clause","id":"reflect","aoid":null,"title":"The Reflect Object","titleHTML":"The Reflect Object","number":"4.1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"The Reflect Object"},{"type":"clause","id":"reflection","aoid":null,"title":"Reflection","titleHTML":"Reflection","number":"4","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","referencingIds":[],"key":"Reflection"}]</script><script>"use strict";
|
---|
13 |
|
---|
14 | function Search(menu) {
|
---|
15 | this.menu = menu;
|
---|
16 | this.$search = document.getElementById('menu-search');
|
---|
17 | this.$searchBox = document.getElementById('menu-search-box');
|
---|
18 | this.$searchResults = document.getElementById('menu-search-results');
|
---|
19 |
|
---|
20 | this.loadBiblio();
|
---|
21 |
|
---|
22 | document.addEventListener('keydown', this.documentKeydown.bind(this));
|
---|
23 |
|
---|
24 | this.$searchBox.addEventListener('keydown', debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true }));
|
---|
25 | this.$searchBox.addEventListener('keyup', debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true }));
|
---|
26 | }
|
---|
27 |
|
---|
28 | Search.prototype.loadBiblio = function () {
|
---|
29 | var $biblio = document.getElementById('menu-search-biblio');
|
---|
30 | if (!$biblio) {
|
---|
31 | this.biblio = [];
|
---|
32 | } else {
|
---|
33 | this.biblio = JSON.parse($biblio.textContent);
|
---|
34 | this.biblio.clauses = this.biblio.filter(function (e) { return e.type === 'clause' });
|
---|
35 | this.biblio.byId = this.biblio.reduce(function (map, entry) {
|
---|
36 | map[entry.id] = entry;
|
---|
37 | return map;
|
---|
38 | }, {});
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | Search.prototype.documentKeydown = function (e) {
|
---|
43 | if (e.keyCode === 191) {
|
---|
44 | e.preventDefault();
|
---|
45 | e.stopPropagation();
|
---|
46 | this.triggerSearch();
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | Search.prototype.searchBoxKeydown = function (e) {
|
---|
51 | e.stopPropagation();
|
---|
52 | e.preventDefault();
|
---|
53 | if (e.keyCode === 191 && e.target.value.length === 0) {
|
---|
54 | e.preventDefault();
|
---|
55 | } else if (e.keyCode === 13) {
|
---|
56 | e.preventDefault();
|
---|
57 | this.selectResult();
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | Search.prototype.searchBoxKeyup = function (e) {
|
---|
62 | if (e.keyCode === 13 || e.keyCode === 9) {
|
---|
63 | return;
|
---|
64 | }
|
---|
65 |
|
---|
66 | this.search(e.target.value);
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | Search.prototype.triggerSearch = function (e) {
|
---|
71 | if (this.menu.isVisible()) {
|
---|
72 | this._closeAfterSearch = false;
|
---|
73 | } else {
|
---|
74 | this._closeAfterSearch = true;
|
---|
75 | this.menu.show();
|
---|
76 | }
|
---|
77 |
|
---|
78 | this.$searchBox.focus();
|
---|
79 | this.$searchBox.select();
|
---|
80 | }
|
---|
81 | // bit 12 - Set if the result starts with searchString
|
---|
82 | // bits 8-11: 8 - number of chunks multiplied by 2 if cases match, otherwise 1.
|
---|
83 | // bits 1-7: 127 - length of the entry
|
---|
84 | // General scheme: prefer case sensitive matches with fewer chunks, and otherwise
|
---|
85 | // prefer shorter matches.
|
---|
86 | function relevance(result, searchString) {
|
---|
87 | var relevance = 0;
|
---|
88 |
|
---|
89 | relevance = Math.max(0, 8 - result.match.chunks) << 7;
|
---|
90 |
|
---|
91 | if (result.match.caseMatch) {
|
---|
92 | relevance *= 2;
|
---|
93 | }
|
---|
94 |
|
---|
95 | if (result.match.prefix) {
|
---|
96 | relevance += 2048
|
---|
97 | }
|
---|
98 |
|
---|
99 | relevance += Math.max(0, 255 - result.entry.key.length);
|
---|
100 |
|
---|
101 | return relevance;
|
---|
102 | }
|
---|
103 |
|
---|
104 | Search.prototype.search = function (searchString) {
|
---|
105 | var s = Date.now();
|
---|
106 |
|
---|
107 | if (searchString === '') {
|
---|
108 | this.displayResults([]);
|
---|
109 | this.hideSearch();
|
---|
110 | return;
|
---|
111 | } else {
|
---|
112 | this.showSearch();
|
---|
113 | }
|
---|
114 |
|
---|
115 | if (searchString.length === 1) {
|
---|
116 | this.displayResults([]);
|
---|
117 | return;
|
---|
118 | }
|
---|
119 |
|
---|
120 | var results;
|
---|
121 |
|
---|
122 | if (/^[\d\.]*$/.test(searchString)) {
|
---|
123 | results = this.biblio.clauses.filter(function (clause) {
|
---|
124 | return clause.number.substring(0, searchString.length) === searchString;
|
---|
125 | }).map(function (clause) {
|
---|
126 | return { entry: clause };
|
---|
127 | });
|
---|
128 | } else {
|
---|
129 | results = [];
|
---|
130 |
|
---|
131 | for (var i = 0; i < this.biblio.length; i++) {
|
---|
132 | var entry = this.biblio[i];
|
---|
133 | if (!entry.key) {
|
---|
134 | // biblio entries without a key aren't searchable
|
---|
135 | continue;
|
---|
136 | }
|
---|
137 |
|
---|
138 | var match = fuzzysearch(searchString, entry.key);
|
---|
139 | if (match) {
|
---|
140 | results.push({ entry: entry, match: match });
|
---|
141 | }
|
---|
142 | }
|
---|
143 |
|
---|
144 | results.forEach(function (result) {
|
---|
145 | result.relevance = relevance(result, searchString);
|
---|
146 | });
|
---|
147 |
|
---|
148 | results = results.sort(function (a, b) { return b.relevance - a.relevance });
|
---|
149 |
|
---|
150 | }
|
---|
151 |
|
---|
152 | if (results.length > 50) {
|
---|
153 | results = results.slice(0, 50);
|
---|
154 | }
|
---|
155 |
|
---|
156 | this.displayResults(results);
|
---|
157 | }
|
---|
158 | Search.prototype.hideSearch = function () {
|
---|
159 | this.$search.classList.remove('active');
|
---|
160 | }
|
---|
161 |
|
---|
162 | Search.prototype.showSearch = function () {
|
---|
163 | this.$search.classList.add('active');
|
---|
164 | }
|
---|
165 |
|
---|
166 | Search.prototype.selectResult = function () {
|
---|
167 | var $first = this.$searchResults.querySelector('li:first-child a');
|
---|
168 |
|
---|
169 | if ($first) {
|
---|
170 | document.location = $first.getAttribute('href');
|
---|
171 | }
|
---|
172 |
|
---|
173 | this.$searchBox.value = '';
|
---|
174 | this.$searchBox.blur();
|
---|
175 | this.displayResults([]);
|
---|
176 | this.hideSearch();
|
---|
177 |
|
---|
178 | if (this._closeAfterSearch) {
|
---|
179 | this.menu.hide();
|
---|
180 | }
|
---|
181 | }
|
---|
182 |
|
---|
183 | Search.prototype.displayResults = function (results) {
|
---|
184 | if (results.length > 0) {
|
---|
185 | this.$searchResults.classList.remove('no-results');
|
---|
186 |
|
---|
187 | var html = '<ul>';
|
---|
188 |
|
---|
189 | results.forEach(function (result) {
|
---|
190 | var entry = result.entry;
|
---|
191 | var id = entry.id;
|
---|
192 | var cssClass = '';
|
---|
193 | var text = '';
|
---|
194 |
|
---|
195 | if (entry.type === 'clause') {
|
---|
196 | var number = entry.number ? entry.number + ' ' : '';
|
---|
197 | text = number + entry.key;
|
---|
198 | cssClass = 'clause';
|
---|
199 | id = entry.id;
|
---|
200 | } else if (entry.type === 'production') {
|
---|
201 | text = entry.key;
|
---|
202 | cssClass = 'prod';
|
---|
203 | id = entry.id;
|
---|
204 | } else if (entry.type === 'op') {
|
---|
205 | text = entry.key;
|
---|
206 | cssClass = 'op';
|
---|
207 | id = entry.id || entry.refId;
|
---|
208 | } else if (entry.type === 'term') {
|
---|
209 | text = entry.key;
|
---|
210 | cssClass = 'term';
|
---|
211 | id = entry.id || entry.refId;
|
---|
212 | }
|
---|
213 |
|
---|
214 | if (text) {
|
---|
215 | html += '<li class=menu-search-result-' + cssClass + '><a href="#' + id + '">' + text + '</a></li>'
|
---|
216 | }
|
---|
217 | });
|
---|
218 |
|
---|
219 | html += '</ul>'
|
---|
220 |
|
---|
221 | this.$searchResults.innerHTML = html;
|
---|
222 | } else {
|
---|
223 | this.$searchResults.innerHTML = '';
|
---|
224 | this.$searchResults.classList.add('no-results');
|
---|
225 | }
|
---|
226 | }
|
---|
227 |
|
---|
228 |
|
---|
229 | function Menu() {
|
---|
230 | this.$toggle = document.getElementById('menu-toggle');
|
---|
231 | this.$menu = document.getElementById('menu');
|
---|
232 | this.$toc = document.querySelector('menu-toc > ol');
|
---|
233 | this.$pins = document.querySelector('#menu-pins');
|
---|
234 | this.$pinList = document.getElementById('menu-pins-list');
|
---|
235 | this.$toc = document.querySelector('#menu-toc > ol');
|
---|
236 | this.$specContainer = document.getElementById('spec-container');
|
---|
237 | this.search = new Search(this);
|
---|
238 |
|
---|
239 | this._pinnedIds = {};
|
---|
240 | this.loadPinEntries();
|
---|
241 |
|
---|
242 | // toggle menu
|
---|
243 | this.$toggle.addEventListener('click', this.toggle.bind(this));
|
---|
244 |
|
---|
245 | // keydown events for pinned clauses
|
---|
246 | document.addEventListener('keydown', this.documentKeydown.bind(this));
|
---|
247 |
|
---|
248 | // toc expansion
|
---|
249 | var tocItems = this.$menu.querySelectorAll('#menu-toc li');
|
---|
250 | for (var i = 0; i < tocItems.length; i++) {
|
---|
251 | var $item = tocItems[i];
|
---|
252 | $item.addEventListener('click', function($item, event) {
|
---|
253 | $item.classList.toggle('active');
|
---|
254 | event.stopPropagation();
|
---|
255 | }.bind(null, $item));
|
---|
256 | }
|
---|
257 |
|
---|
258 | // close toc on toc item selection
|
---|
259 | var tocLinks = this.$menu.querySelectorAll('#menu-toc li > a');
|
---|
260 | for (var i = 0; i < tocLinks.length; i++) {
|
---|
261 | var $link = tocLinks[i];
|
---|
262 | $link.addEventListener('click', function(event) {
|
---|
263 | this.toggle();
|
---|
264 | event.stopPropagation();
|
---|
265 | }.bind(this));
|
---|
266 | }
|
---|
267 |
|
---|
268 | // update active clause on scroll
|
---|
269 | window.addEventListener('scroll', debounce(this.updateActiveClause.bind(this)));
|
---|
270 | this.updateActiveClause();
|
---|
271 |
|
---|
272 | // prevent menu scrolling from scrolling the body
|
---|
273 | this.$toc.addEventListener('wheel', function (e) {
|
---|
274 | var target = e.currentTarget;
|
---|
275 | var offTop = e.deltaY < 0 && target.scrollTop === 0;
|
---|
276 | if (offTop) {
|
---|
277 | e.preventDefault();
|
---|
278 | }
|
---|
279 | var offBottom = e.deltaY > 0
|
---|
280 | && target.offsetHeight + target.scrollTop >= target.scrollHeight;
|
---|
281 |
|
---|
282 | if (offBottom) {
|
---|
283 | e.preventDefault();
|
---|
284 | }
|
---|
285 | })
|
---|
286 | }
|
---|
287 |
|
---|
288 | Menu.prototype.documentKeydown = function (e) {
|
---|
289 | e.stopPropagation();
|
---|
290 | if (e.keyCode === 80) {
|
---|
291 | this.togglePinEntry();
|
---|
292 | } else if (e.keyCode > 48 && e.keyCode < 58) {
|
---|
293 | this.selectPin(e.keyCode - 49);
|
---|
294 | }
|
---|
295 | }
|
---|
296 |
|
---|
297 | Menu.prototype.updateActiveClause = function () {
|
---|
298 | this.setActiveClause(findActiveClause(this.$specContainer))
|
---|
299 | }
|
---|
300 |
|
---|
301 | Menu.prototype.setActiveClause = function (clause) {
|
---|
302 | this.$activeClause = clause;
|
---|
303 | this.revealInToc(this.$activeClause);
|
---|
304 | }
|
---|
305 |
|
---|
306 | Menu.prototype.revealInToc = function (path) {
|
---|
307 | var current = this.$toc.querySelectorAll('li.revealed');
|
---|
308 | for (var i = 0; i < current.length; i++) {
|
---|
309 | current[i].classList.remove('revealed');
|
---|
310 | current[i].classList.remove('revealed-leaf');
|
---|
311 | }
|
---|
312 |
|
---|
313 | var current = this.$toc;
|
---|
314 | var index = 0;
|
---|
315 | while (index < path.length) {
|
---|
316 | var children = current.children;
|
---|
317 | for (var i = 0; i < children.length; i++) {
|
---|
318 | if ('#' + path[index].id === children[i].children[1].getAttribute('href') ) {
|
---|
319 | children[i].classList.add('revealed');
|
---|
320 | if (index === path.length - 1) {
|
---|
321 | children[i].classList.add('revealed-leaf');
|
---|
322 | var rect = children[i].getBoundingClientRect();
|
---|
323 | this.$toc.getBoundingClientRect().top
|
---|
324 | var tocRect = this.$toc.getBoundingClientRect();
|
---|
325 | if (rect.top + 10 > tocRect.bottom) {
|
---|
326 | this.$toc.scrollTop = this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top);
|
---|
327 | } else if (rect.top < tocRect.top) {
|
---|
328 | this.$toc.scrollTop = this.$toc.scrollTop - (tocRect.top - rect.top);
|
---|
329 | }
|
---|
330 | }
|
---|
331 | current = children[i].querySelector('ol');
|
---|
332 | index++;
|
---|
333 | break;
|
---|
334 | }
|
---|
335 | }
|
---|
336 |
|
---|
337 | }
|
---|
338 | }
|
---|
339 |
|
---|
340 | function findActiveClause(root, path) {
|
---|
341 | var clauses = new ClauseWalker(root);
|
---|
342 | var $clause;
|
---|
343 | var found = false;
|
---|
344 | var path = path || [];
|
---|
345 |
|
---|
346 | while ($clause = clauses.nextNode()) {
|
---|
347 | var rect = $clause.getBoundingClientRect();
|
---|
348 | var $header = $clause.children[0];
|
---|
349 | var marginTop = parseInt(getComputedStyle($header)["margin-top"]);
|
---|
350 |
|
---|
351 | if ((rect.top - marginTop) <= 0 && rect.bottom > 0) {
|
---|
352 | found = true;
|
---|
353 | return findActiveClause($clause, path.concat($clause)) || path;
|
---|
354 | }
|
---|
355 | }
|
---|
356 |
|
---|
357 | return path;
|
---|
358 | }
|
---|
359 |
|
---|
360 | function ClauseWalker(root) {
|
---|
361 | var previous;
|
---|
362 | var treeWalker = document.createTreeWalker(
|
---|
363 | root,
|
---|
364 | NodeFilter.SHOW_ELEMENT,
|
---|
365 | {
|
---|
366 | acceptNode: function (node) {
|
---|
367 | if (previous === node.parentNode) {
|
---|
368 | return NodeFilter.FILTER_REJECT;
|
---|
369 | } else {
|
---|
370 | previous = node;
|
---|
371 | }
|
---|
372 | if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-INTRO' || node.nodeName === 'EMU-ANNEX') {
|
---|
373 | return NodeFilter.FILTER_ACCEPT;
|
---|
374 | } else {
|
---|
375 | return NodeFilter.FILTER_SKIP;
|
---|
376 | }
|
---|
377 | }
|
---|
378 | },
|
---|
379 | false
|
---|
380 | );
|
---|
381 |
|
---|
382 | return treeWalker;
|
---|
383 | }
|
---|
384 |
|
---|
385 | Menu.prototype.toggle = function () {
|
---|
386 | this.$menu.classList.toggle('active');
|
---|
387 | }
|
---|
388 |
|
---|
389 | Menu.prototype.show = function () {
|
---|
390 | this.$menu.classList.add('active');
|
---|
391 | }
|
---|
392 |
|
---|
393 | Menu.prototype.hide = function () {
|
---|
394 | this.$menu.classList.remove('active');
|
---|
395 | }
|
---|
396 |
|
---|
397 | Menu.prototype.isVisible = function() {
|
---|
398 | return this.$menu.classList.contains('active');
|
---|
399 | }
|
---|
400 |
|
---|
401 | Menu.prototype.showPins = function () {
|
---|
402 | this.$pins.classList.add('active');
|
---|
403 | }
|
---|
404 |
|
---|
405 | Menu.prototype.hidePins = function () {
|
---|
406 | this.$pins.classList.remove('active');
|
---|
407 | }
|
---|
408 |
|
---|
409 | Menu.prototype.addPinEntry = function (id) {
|
---|
410 | var entry = this.search.biblio.byId[id];
|
---|
411 | if (!entry) {
|
---|
412 | // id was deleted after pin (or something) so remove it
|
---|
413 | delete this._pinnedIds[id];
|
---|
414 | this.persistPinEntries();
|
---|
415 | return;
|
---|
416 | }
|
---|
417 |
|
---|
418 | if (entry.type === 'clause') {
|
---|
419 | var prefix;
|
---|
420 | if (entry.number) {
|
---|
421 | prefix = entry.number + ' ';
|
---|
422 | } else {
|
---|
423 | prefix = '';
|
---|
424 | }
|
---|
425 | this.$pinList.innerHTML += '<li><a href="#' + entry.id + '">' + prefix + entry.titleHTML + '</a></li>';
|
---|
426 | } else {
|
---|
427 | this.$pinList.innerHTML += '<li><a href="#' + entry.id + '">' + entry.key + '</a></li>';
|
---|
428 | }
|
---|
429 |
|
---|
430 | if (Object.keys(this._pinnedIds).length === 0) {
|
---|
431 | this.showPins();
|
---|
432 | }
|
---|
433 | this._pinnedIds[id] = true;
|
---|
434 | this.persistPinEntries();
|
---|
435 | }
|
---|
436 |
|
---|
437 | Menu.prototype.removePinEntry = function (id) {
|
---|
438 | var item = this.$pinList.querySelector('a[href="#' + id + '"]').parentNode;
|
---|
439 | this.$pinList.removeChild(item);
|
---|
440 | delete this._pinnedIds[id];
|
---|
441 | if (Object.keys(this._pinnedIds).length === 0) {
|
---|
442 | this.hidePins();
|
---|
443 | }
|
---|
444 |
|
---|
445 | this.persistPinEntries();
|
---|
446 | }
|
---|
447 |
|
---|
448 | Menu.prototype.persistPinEntries = function () {
|
---|
449 | try {
|
---|
450 | if (!window.localStorage) return;
|
---|
451 | } catch (e) {
|
---|
452 | return;
|
---|
453 | }
|
---|
454 |
|
---|
455 | localStorage.pinEntries = JSON.stringify(Object.keys(this._pinnedIds));
|
---|
456 | }
|
---|
457 |
|
---|
458 | Menu.prototype.loadPinEntries = function () {
|
---|
459 | try {
|
---|
460 | if (!window.localStorage) return;
|
---|
461 | } catch (e) {
|
---|
462 | return;
|
---|
463 | }
|
---|
464 |
|
---|
465 | var pinsString = window.localStorage.pinEntries;
|
---|
466 | if (!pinsString) return;
|
---|
467 | var pins = JSON.parse(pinsString);
|
---|
468 | for(var i = 0; i < pins.length; i++) {
|
---|
469 | this.addPinEntry(pins[i]);
|
---|
470 | }
|
---|
471 | }
|
---|
472 |
|
---|
473 | Menu.prototype.togglePinEntry = function (id) {
|
---|
474 | if (!id) {
|
---|
475 | id = this.$activeClause[this.$activeClause.length - 1].id;
|
---|
476 | }
|
---|
477 |
|
---|
478 | if (this._pinnedIds[id]) {
|
---|
479 | this.removePinEntry(id);
|
---|
480 | } else {
|
---|
481 | this.addPinEntry(id);
|
---|
482 | }
|
---|
483 | }
|
---|
484 |
|
---|
485 | Menu.prototype.selectPin = function (num) {
|
---|
486 | document.location = this.$pinList.children[num].children[0].href;
|
---|
487 | }
|
---|
488 |
|
---|
489 | var menu;
|
---|
490 | function init() {
|
---|
491 | menu = new Menu();
|
---|
492 | var $container = document.getElementById('spec-container');
|
---|
493 | $container.addEventListener('mouseover', debounce(function (e) {
|
---|
494 | Toolbox.activateIfMouseOver(e);
|
---|
495 | }));
|
---|
496 | }
|
---|
497 |
|
---|
498 | document.addEventListener('DOMContentLoaded', init);
|
---|
499 |
|
---|
500 | function debounce(fn, opts) {
|
---|
501 | opts = opts || {};
|
---|
502 | var timeout;
|
---|
503 | return function(e) {
|
---|
504 | if (opts.stopPropagation) {
|
---|
505 | e.stopPropagation();
|
---|
506 | }
|
---|
507 | var args = arguments;
|
---|
508 | if (timeout) {
|
---|
509 | clearTimeout(timeout);
|
---|
510 | }
|
---|
511 | timeout = setTimeout(function() {
|
---|
512 | timeout = null;
|
---|
513 | fn.apply(this, args);
|
---|
514 | }.bind(this), 150);
|
---|
515 | }
|
---|
516 | }
|
---|
517 |
|
---|
518 | var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX'];
|
---|
519 | function findLocalReferences ($elem) {
|
---|
520 | var name = $elem.innerHTML;
|
---|
521 | var references = [];
|
---|
522 |
|
---|
523 | var parentClause = $elem.parentNode;
|
---|
524 | while (parentClause && CLAUSE_NODES.indexOf(parentClause.nodeName) === -1) {
|
---|
525 | parentClause = parentClause.parentNode;
|
---|
526 | }
|
---|
527 |
|
---|
528 | if(!parentClause) return;
|
---|
529 |
|
---|
530 | var vars = parentClause.querySelectorAll('var');
|
---|
531 |
|
---|
532 | for (var i = 0; i < vars.length; i++) {
|
---|
533 | var $var = vars[i];
|
---|
534 |
|
---|
535 | if ($var.innerHTML === name) {
|
---|
536 | references.push($var);
|
---|
537 | }
|
---|
538 | }
|
---|
539 |
|
---|
540 | return references;
|
---|
541 | }
|
---|
542 |
|
---|
543 | function toggleFindLocalReferences($elem) {
|
---|
544 | var references = findLocalReferences($elem);
|
---|
545 | if ($elem.classList.contains('referenced')) {
|
---|
546 | references.forEach(function ($reference) {
|
---|
547 | $reference.classList.remove('referenced');
|
---|
548 | });
|
---|
549 | } else {
|
---|
550 | references.forEach(function ($reference) {
|
---|
551 | $reference.classList.add('referenced');
|
---|
552 | });
|
---|
553 | }
|
---|
554 | }
|
---|
555 |
|
---|
556 | function installFindLocalReferences () {
|
---|
557 | document.addEventListener('click', function (e) {
|
---|
558 | if (e.target.nodeName === 'VAR') {
|
---|
559 | toggleFindLocalReferences(e.target);
|
---|
560 | }
|
---|
561 | });
|
---|
562 | }
|
---|
563 |
|
---|
564 | document.addEventListener('DOMContentLoaded', installFindLocalReferences);
|
---|
565 |
|
---|
566 |
|
---|
567 |
|
---|
568 |
|
---|
569 | // The following license applies to the fuzzysearch function
|
---|
570 | // The MIT License (MIT)
|
---|
571 | // Copyright © 2015 Nicolas Bevacqua
|
---|
572 | // Copyright © 2016 Brian Terlson
|
---|
573 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
|
---|
574 | // this software and associated documentation files (the "Software"), to deal in
|
---|
575 | // the Software without restriction, including without limitation the rights to
|
---|
576 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
---|
577 | // the Software, and to permit persons to whom the Software is furnished to do so,
|
---|
578 | // subject to the following conditions:
|
---|
579 |
|
---|
580 | // The above copyright notice and this permission notice shall be included in all
|
---|
581 | // copies or substantial portions of the Software.
|
---|
582 |
|
---|
583 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
584 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
---|
585 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
---|
586 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
---|
587 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
588 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
589 | function fuzzysearch (searchString, haystack, caseInsensitive) {
|
---|
590 | var tlen = haystack.length;
|
---|
591 | var qlen = searchString.length;
|
---|
592 | var chunks = 1;
|
---|
593 | var finding = false;
|
---|
594 | var prefix = true;
|
---|
595 |
|
---|
596 | if (qlen > tlen) {
|
---|
597 | return false;
|
---|
598 | }
|
---|
599 |
|
---|
600 | if (qlen === tlen) {
|
---|
601 | if (searchString === haystack) {
|
---|
602 | return { caseMatch: true, chunks: 1, prefix: true };
|
---|
603 | } else if (searchString.toLowerCase() === haystack.toLowerCase()) {
|
---|
604 | return { caseMatch: false, chunks: 1, prefix: true };
|
---|
605 | } else {
|
---|
606 | return false;
|
---|
607 | }
|
---|
608 | }
|
---|
609 |
|
---|
610 | outer: for (var i = 0, j = 0; i < qlen; i++) {
|
---|
611 | var nch = searchString[i];
|
---|
612 | while (j < tlen) {
|
---|
613 | var targetChar = haystack[j++];
|
---|
614 | if (targetChar === nch) {
|
---|
615 | finding = true;
|
---|
616 | continue outer;
|
---|
617 | }
|
---|
618 | if (finding) {
|
---|
619 | chunks++;
|
---|
620 | finding = false;
|
---|
621 | }
|
---|
622 | }
|
---|
623 |
|
---|
624 | if (caseInsensitive) { return false }
|
---|
625 |
|
---|
626 | return fuzzysearch(searchString.toLowerCase(), haystack.toLowerCase(), true);
|
---|
627 | }
|
---|
628 |
|
---|
629 | return { caseMatch: !caseInsensitive, chunks: chunks, prefix: j <= qlen };
|
---|
630 | }
|
---|
631 |
|
---|
632 | var Toolbox = {
|
---|
633 | init: function () {
|
---|
634 | this.$container = document.createElement('div');
|
---|
635 | this.$container.classList.add('toolbox');
|
---|
636 | this.$permalink = document.createElement('a');
|
---|
637 | this.$permalink.textContent = 'Permalink';
|
---|
638 | this.$pinLink = document.createElement('a');
|
---|
639 | this.$pinLink.textContent = 'Pin';
|
---|
640 | this.$pinLink.setAttribute('href', '#');
|
---|
641 | this.$pinLink.addEventListener('click', function (e) {
|
---|
642 | e.preventDefault();
|
---|
643 | e.stopPropagation();
|
---|
644 | menu.togglePinEntry(this.entry.id);
|
---|
645 | }.bind(this));
|
---|
646 |
|
---|
647 | this.$refsLink = document.createElement('a');
|
---|
648 | this.$refsLink.setAttribute('href', '#');
|
---|
649 | this.$refsLink.addEventListener('click', function (e) {
|
---|
650 | e.preventDefault();
|
---|
651 | e.stopPropagation();
|
---|
652 | referencePane.showReferencesFor(this.entry);
|
---|
653 | }.bind(this));
|
---|
654 | this.$container.appendChild(this.$permalink);
|
---|
655 | this.$container.appendChild(this.$pinLink);
|
---|
656 | this.$container.appendChild(this.$refsLink);
|
---|
657 | document.body.appendChild(this.$container);
|
---|
658 | },
|
---|
659 |
|
---|
660 | activate: function (el, entry, target) {
|
---|
661 | if (el === this._activeEl) return;
|
---|
662 | this.active = true;
|
---|
663 | this.entry = entry;
|
---|
664 | this.$container.classList.add('active');
|
---|
665 | this.top = el.offsetTop - this.$container.offsetHeight - 10;
|
---|
666 | this.left = el.offsetLeft;
|
---|
667 | this.$container.setAttribute('style', 'left: ' + this.left + 'px; top: ' + this.top + 'px');
|
---|
668 | this.updatePermalink();
|
---|
669 | this.updateReferences();
|
---|
670 | this._activeEl = el;
|
---|
671 | if (this.top < document.body.scrollTop && el === target) {
|
---|
672 | // don't scroll unless it's a small thing (< 200px)
|
---|
673 | this.$container.scrollIntoView();
|
---|
674 | }
|
---|
675 | },
|
---|
676 |
|
---|
677 | updatePermalink: function () {
|
---|
678 | this.$permalink.setAttribute('href', '#' + this.entry.id);
|
---|
679 | },
|
---|
680 |
|
---|
681 | updateReferences: function () {
|
---|
682 | this.$refsLink.textContent = 'References (' + this.entry.referencingIds.length + ')';
|
---|
683 | },
|
---|
684 |
|
---|
685 | activateIfMouseOver: function (e) {
|
---|
686 | var ref = this.findReferenceUnder(e.target);
|
---|
687 | if (ref && (!this.active || e.pageY > this._activeEl.offsetTop)) {
|
---|
688 | var entry = menu.search.biblio.byId[ref.id];
|
---|
689 | this.activate(ref.element, entry, e.target);
|
---|
690 | } else if (this.active && ((e.pageY < this.top) || e.pageY > (this._activeEl.offsetTop + this._activeEl.offsetHeight))) {
|
---|
691 | this.deactivate();
|
---|
692 | }
|
---|
693 | },
|
---|
694 |
|
---|
695 | findReferenceUnder: function (el) {
|
---|
696 | while (el) {
|
---|
697 | var parent = el.parentNode;
|
---|
698 | if (el.nodeName === 'H1' && parent.nodeName.match(/EMU-CLAUSE|EMU-ANNEX|EMU-INTRO/) && parent.id) {
|
---|
699 | return { element: el, id: parent.id };
|
---|
700 | } else if (el.nodeName.match(/EMU-(?!CLAUSE|XREF|ANNEX|INTRO)|DFN/) &&
|
---|
701 | el.id && el.id[0] !== '_') {
|
---|
702 | if (el.nodeName === 'EMU-FIGURE' || el.nodeName === 'EMU-TABLE' || el.nodeName === 'EMU-EXAMPLE') {
|
---|
703 | // return the figcaption element
|
---|
704 | return { element: el.children[0].children[0], id: el.id };
|
---|
705 | } else if (el.nodeName === 'EMU-PRODUCTION') {
|
---|
706 | // return the LHS non-terminal element
|
---|
707 | return { element: el.children[0], id: el.id };
|
---|
708 | } else {
|
---|
709 | return { element: el, id: el.id };
|
---|
710 | }
|
---|
711 | }
|
---|
712 | el = parent;
|
---|
713 | }
|
---|
714 | },
|
---|
715 |
|
---|
716 | deactivate: function () {
|
---|
717 | this.$container.classList.remove('active');
|
---|
718 | this._activeEl = null;
|
---|
719 | this.activeElBounds = null;
|
---|
720 | this.active = false;
|
---|
721 | }
|
---|
722 | }
|
---|
723 |
|
---|
724 | var referencePane = {
|
---|
725 | init: function() {
|
---|
726 | this.$container = document.createElement('div');
|
---|
727 | this.$container.setAttribute('id', 'references-pane-container');
|
---|
728 |
|
---|
729 | var $spacer = document.createElement('div');
|
---|
730 | $spacer.setAttribute('id', 'references-pane-spacer');
|
---|
731 |
|
---|
732 | this.$pane = document.createElement('div');
|
---|
733 | this.$pane.setAttribute('id', 'references-pane');
|
---|
734 |
|
---|
735 | this.$container.appendChild($spacer);
|
---|
736 | this.$container.appendChild(this.$pane);
|
---|
737 |
|
---|
738 | this.$header = document.createElement('div');
|
---|
739 | this.$header.classList.add('menu-pane-header');
|
---|
740 | this.$header.textContent = 'References to ';
|
---|
741 | this.$headerRefId = document.createElement('a');
|
---|
742 | this.$header.appendChild(this.$headerRefId);
|
---|
743 | this.$closeButton = document.createElement('span');
|
---|
744 | this.$closeButton.setAttribute('id', 'references-pane-close');
|
---|
745 | this.$closeButton.addEventListener('click', function (e) {
|
---|
746 | this.deactivate();
|
---|
747 | }.bind(this));
|
---|
748 | this.$header.appendChild(this.$closeButton);
|
---|
749 |
|
---|
750 | this.$pane.appendChild(this.$header);
|
---|
751 | var tableContainer = document.createElement('div');
|
---|
752 | tableContainer.setAttribute('id', 'references-pane-table-container');
|
---|
753 |
|
---|
754 | this.$table = document.createElement('table');
|
---|
755 | this.$table.setAttribute('id', 'references-pane-table');
|
---|
756 |
|
---|
757 | this.$tableBody = this.$table.createTBody();
|
---|
758 |
|
---|
759 | tableContainer.appendChild(this.$table);
|
---|
760 | this.$pane.appendChild(tableContainer);
|
---|
761 |
|
---|
762 | menu.$specContainer.appendChild(this.$container);
|
---|
763 | },
|
---|
764 |
|
---|
765 | activate: function () {
|
---|
766 | this.$container.classList.add('active');
|
---|
767 | },
|
---|
768 |
|
---|
769 | deactivate: function () {
|
---|
770 | this.$container.classList.remove('active');
|
---|
771 | },
|
---|
772 |
|
---|
773 | showReferencesFor(entry) {
|
---|
774 | this.activate();
|
---|
775 | var newBody = document.createElement('tbody');
|
---|
776 | var previousId;
|
---|
777 | var previousCell;
|
---|
778 | var dupCount = 0;
|
---|
779 | this.$headerRefId.textContent = '#' + entry.id;
|
---|
780 | this.$headerRefId.setAttribute('href', '#' + entry.id);
|
---|
781 | entry.referencingIds.map(function (id) {
|
---|
782 | var target = document.getElementById(id);
|
---|
783 | var cid = findParentClauseId(target);
|
---|
784 | var clause = menu.search.biblio.byId[cid];
|
---|
785 | var dupCount = 0;
|
---|
786 | return { id: id, clause: clause }
|
---|
787 | }).sort(function (a, b) {
|
---|
788 | return sortByClauseNumber(a.clause, b.clause);
|
---|
789 | }).forEach(function (record, i) {
|
---|
790 | if (previousId === record.clause.id) {
|
---|
791 | previousCell.innerHTML += ' (<a href="#' + record.id + '">' + (dupCount + 2) + '</a>)';
|
---|
792 | dupCount++;
|
---|
793 | } else {
|
---|
794 | var row = newBody.insertRow();
|
---|
795 | var cell = row.insertCell();
|
---|
796 | cell.innerHTML = record.clause.number;
|
---|
797 | cell = row.insertCell();
|
---|
798 | cell.innerHTML = '<a href="#' + record.id + '">' + record.clause.titleHTML + '</a>';
|
---|
799 | previousCell = cell;
|
---|
800 | previousId = record.clause.id;
|
---|
801 | dupCount = 0;
|
---|
802 | }
|
---|
803 | }, this);
|
---|
804 | this.$table.removeChild(this.$tableBody);
|
---|
805 | this.$tableBody = newBody;
|
---|
806 | this.$table.appendChild(this.$tableBody);
|
---|
807 | }
|
---|
808 | }
|
---|
809 | function findParentClauseId(node) {
|
---|
810 | while (node && node.nodeName !== 'EMU-CLAUSE' && node.nodeName !== 'EMU-INTRO' && node.nodeName !== 'EMU-ANNEX') {
|
---|
811 | node = node.parentNode;
|
---|
812 | }
|
---|
813 | if (!node) return null;
|
---|
814 | return node.getAttribute('id');
|
---|
815 | }
|
---|
816 |
|
---|
817 | function sortByClauseNumber(c1, c2) {
|
---|
818 | var c1c = c1.number.split('.');
|
---|
819 | var c2c = c2.number.split('.');
|
---|
820 |
|
---|
821 | for (var i = 0; i < c1c.length; i++) {
|
---|
822 | if (i >= c2c.length) {
|
---|
823 | return 1;
|
---|
824 | }
|
---|
825 |
|
---|
826 | var c1 = c1c[i];
|
---|
827 | var c2 = c2c[i];
|
---|
828 | var c1cn = Number(c1);
|
---|
829 | var c2cn = Number(c2);
|
---|
830 |
|
---|
831 | if (Number.isNaN(c1cn) && Number.isNaN(c2cn)) {
|
---|
832 | if (c1 > c2) {
|
---|
833 | return 1;
|
---|
834 | } else if (c1 < c2) {
|
---|
835 | return -1;
|
---|
836 | }
|
---|
837 | } else if (!Number.isNaN(c1cn) && Number.isNaN(c2cn)) {
|
---|
838 | return -1;
|
---|
839 | } else if (Number.isNaN(c1cn) && !Number.isNaN(c2cn)) {
|
---|
840 | return 1;
|
---|
841 | } else if(c1cn > c2cn) {
|
---|
842 | return 1;
|
---|
843 | } else if (c1cn < c2cn) {
|
---|
844 | return -1;
|
---|
845 | }
|
---|
846 | }
|
---|
847 |
|
---|
848 | if (c1c.length === c2c.length) {
|
---|
849 | return 0;
|
---|
850 | }
|
---|
851 | return -1;
|
---|
852 | }
|
---|
853 |
|
---|
854 | document.addEventListener('DOMContentLoaded', function () {
|
---|
855 | Toolbox.init();
|
---|
856 | referencePane.init();
|
---|
857 | })
|
---|
858 | var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX'];
|
---|
859 | function findLocalReferences ($elem) {
|
---|
860 | var name = $elem.innerHTML;
|
---|
861 | var references = [];
|
---|
862 |
|
---|
863 | var parentClause = $elem.parentNode;
|
---|
864 | while (parentClause && CLAUSE_NODES.indexOf(parentClause.nodeName) === -1) {
|
---|
865 | parentClause = parentClause.parentNode;
|
---|
866 | }
|
---|
867 |
|
---|
868 | if(!parentClause) return;
|
---|
869 |
|
---|
870 | var vars = parentClause.querySelectorAll('var');
|
---|
871 |
|
---|
872 | for (var i = 0; i < vars.length; i++) {
|
---|
873 | var $var = vars[i];
|
---|
874 |
|
---|
875 | if ($var.innerHTML === name) {
|
---|
876 | references.push($var);
|
---|
877 | }
|
---|
878 | }
|
---|
879 |
|
---|
880 | return references;
|
---|
881 | }
|
---|
882 |
|
---|
883 | function toggleFindLocalReferences($elem) {
|
---|
884 | var references = findLocalReferences($elem);
|
---|
885 | if ($elem.classList.contains('referenced')) {
|
---|
886 | references.forEach(function ($reference) {
|
---|
887 | $reference.classList.remove('referenced');
|
---|
888 | });
|
---|
889 | } else {
|
---|
890 | references.forEach(function ($reference) {
|
---|
891 | $reference.classList.add('referenced');
|
---|
892 | });
|
---|
893 | }
|
---|
894 | }
|
---|
895 |
|
---|
896 | function installFindLocalReferences () {
|
---|
897 | document.addEventListener('click', function (e) {
|
---|
898 | if (e.target.nodeName === 'VAR') {
|
---|
899 | toggleFindLocalReferences(e.target);
|
---|
900 | }
|
---|
901 | });
|
---|
902 | }
|
---|
903 |
|
---|
904 | document.addEventListener('DOMContentLoaded', installFindLocalReferences);
|
---|
905 | </script><style>body {
|
---|
906 | display: flex;
|
---|
907 | font-size: 18px;
|
---|
908 | line-height: 1.5;
|
---|
909 | font-family: Cambria, Palatino Linotype, Palatino, Liberation Serif, serif;
|
---|
910 | padding: 0;
|
---|
911 | margin: 0;
|
---|
912 | color: #111;
|
---|
913 | }
|
---|
914 |
|
---|
915 | #spec-container {
|
---|
916 | padding: 0 20px;
|
---|
917 | flex-grow: 1;
|
---|
918 | flex-basis: 66%;
|
---|
919 | box-sizing: border-box;
|
---|
920 | overflow: hidden;
|
---|
921 | }
|
---|
922 |
|
---|
923 | body.oldtoc {
|
---|
924 | margin: 0 auto;
|
---|
925 | }
|
---|
926 |
|
---|
927 | a {
|
---|
928 | text-decoration: none;
|
---|
929 | color: #206ca7;
|
---|
930 | }
|
---|
931 |
|
---|
932 | a:visited {
|
---|
933 | color: #206ca7;
|
---|
934 | }
|
---|
935 |
|
---|
936 | a:hover {
|
---|
937 | text-decoration: underline;
|
---|
938 | color: #239dee;
|
---|
939 | }
|
---|
940 |
|
---|
941 |
|
---|
942 | code {
|
---|
943 | font-weight: bold;
|
---|
944 | font-family: Consolas, Monaco, monospace;
|
---|
945 | white-space: pre;
|
---|
946 | }
|
---|
947 |
|
---|
948 | pre code {
|
---|
949 | font-weight: inherit;
|
---|
950 | }
|
---|
951 |
|
---|
952 | pre code.hljs {
|
---|
953 | background-color: #fff;
|
---|
954 | margin: 0;
|
---|
955 | padding: 0;
|
---|
956 | }
|
---|
957 |
|
---|
958 | ol.toc {
|
---|
959 | list-style: none;
|
---|
960 | padding-left: 0;
|
---|
961 | }
|
---|
962 |
|
---|
963 | ol.toc ol.toc {
|
---|
964 | padding-left: 2ex;
|
---|
965 | list-style: none;
|
---|
966 | }
|
---|
967 |
|
---|
968 | var {
|
---|
969 | color: #2aa198;
|
---|
970 | transition: background-color 0.25s ease;
|
---|
971 | cursor: pointer;
|
---|
972 | }
|
---|
973 |
|
---|
974 | var.referenced {
|
---|
975 | background-color: #ffff33;
|
---|
976 | }
|
---|
977 |
|
---|
978 | emu-const {
|
---|
979 | font-family: sans-serif;
|
---|
980 | }
|
---|
981 |
|
---|
982 | emu-val {
|
---|
983 | font-weight: bold;
|
---|
984 | }
|
---|
985 | emu-alg ol, emu-alg ol ol ol ol {
|
---|
986 | list-style-type: decimal;
|
---|
987 | }
|
---|
988 |
|
---|
989 | emu-alg ol ol, emu-alg ol ol ol ol ol {
|
---|
990 | list-style-type: lower-alpha;
|
---|
991 | }
|
---|
992 |
|
---|
993 | emu-alg ol ol ol, ol ol ol ol ol ol {
|
---|
994 | list-style-type: lower-roman;
|
---|
995 | }
|
---|
996 |
|
---|
997 | emu-eqn {
|
---|
998 | display: block;
|
---|
999 | margin-left: 4em;
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | emu-eqn.inline {
|
---|
1003 | display: inline;
|
---|
1004 | margin: 0;
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | emu-eqn div:first-child {
|
---|
1008 | margin-left: -2em;
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 | emu-note {
|
---|
1012 | margin: 1em 0;
|
---|
1013 | color: #666;
|
---|
1014 | border-left: 5px solid #ccc;
|
---|
1015 | display: flex;
|
---|
1016 | flex-direction: row;
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | emu-note > span.note {
|
---|
1020 | flex-basis: 100px;
|
---|
1021 | min-width: 100px;
|
---|
1022 | flex-grow: 0;
|
---|
1023 | flex-shrink: 1;
|
---|
1024 | text-transform: uppercase;
|
---|
1025 | padding-left: 5px;
|
---|
1026 | }
|
---|
1027 |
|
---|
1028 | emu-note[type=editor] {
|
---|
1029 | border-left-color: #faa;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | emu-note > div.note-contents {
|
---|
1033 | flex-grow: 1;
|
---|
1034 | flex-shrink: 1;
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | emu-note > div.note-contents > p:first-of-type {
|
---|
1038 | margin-top: 0;
|
---|
1039 | }
|
---|
1040 |
|
---|
1041 | emu-note > div.note-contents > p:last-of-type {
|
---|
1042 | margin-bottom: 0;
|
---|
1043 | }
|
---|
1044 |
|
---|
1045 | emu-figure {
|
---|
1046 | display: block;
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 | emu-example {
|
---|
1050 | display: block;
|
---|
1051 | margin: 1em 3em;
|
---|
1052 | }
|
---|
1053 |
|
---|
1054 | emu-example figure figcaption {
|
---|
1055 | margin-top: 0.5em;
|
---|
1056 | text-align: left;
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | emu-figure figure,
|
---|
1060 | emu-example figure,
|
---|
1061 | emu-table figure {
|
---|
1062 | display: flex;
|
---|
1063 | flex-direction: column;
|
---|
1064 | align-items: center;
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | emu-production {
|
---|
1068 | display: block;
|
---|
1069 | margin-top: 1em;
|
---|
1070 | margin-bottom: 1em;
|
---|
1071 | margin-left: 5ex;
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 | emu-grammar.inline, emu-production.inline,
|
---|
1075 | emu-grammar.inline emu-production emu-rhs, emu-production.inline emu-rhs,
|
---|
1076 | emu-grammar[collapsed] emu-production emu-rhs, emu-production[collapsed] emu-rhs {
|
---|
1077 | display: inline;
|
---|
1078 | padding-left: 1ex;
|
---|
1079 | margin-left: 0;
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | emu-grammar[collapsed] emu-production, emu-production[collapsed] {
|
---|
1083 | margin: 0;
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 | emu-constraints {
|
---|
1087 | font-size: .75em;
|
---|
1088 | margin-right: 1ex;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | emu-gann {
|
---|
1092 | margin-right: 1ex;
|
---|
1093 | }
|
---|
1094 |
|
---|
1095 | emu-gann emu-t:last-child,
|
---|
1096 | emu-gann emu-nt:last-child {
|
---|
1097 | margin-right: 0;
|
---|
1098 | }
|
---|
1099 |
|
---|
1100 | emu-geq {
|
---|
1101 | margin-left: 1ex;
|
---|
1102 | font-weight: bold;
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 | emu-oneof {
|
---|
1106 | font-weight: bold;
|
---|
1107 | margin-left: 1ex;
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | emu-nt {
|
---|
1111 | display: inline-block;
|
---|
1112 | font-style: italic;
|
---|
1113 | white-space: nowrap;
|
---|
1114 | text-indent: 0;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | emu-nt a, emu-nt a:visited {
|
---|
1118 | color: #333;
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | emu-rhs emu-nt {
|
---|
1122 | margin-right: 1ex;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | emu-t {
|
---|
1126 | display: inline-block;
|
---|
1127 | font-family: monospace;
|
---|
1128 | font-weight: bold;
|
---|
1129 | white-space: nowrap;
|
---|
1130 | text-indent: 0;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | emu-production emu-t {
|
---|
1134 | margin-right: 1ex;
|
---|
1135 | }
|
---|
1136 |
|
---|
1137 | emu-rhs {
|
---|
1138 | display: block;
|
---|
1139 | padding-left: 75px;
|
---|
1140 | text-indent: -25px;
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | emu-mods {
|
---|
1144 | font-size: .85em;
|
---|
1145 | vertical-align: sub;
|
---|
1146 | font-style: normal;
|
---|
1147 | font-weight: normal;
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | emu-production[collapsed] emu-mods {
|
---|
1151 | display: none;
|
---|
1152 | }
|
---|
1153 |
|
---|
1154 | emu-params, emu-opt {
|
---|
1155 | margin-right: 1ex;
|
---|
1156 | font-family: monospace;
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | emu-params, emu-constraints {
|
---|
1160 | color: #2aa198;
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 | emu-opt {
|
---|
1164 | color: #b58900;
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | emu-gprose {
|
---|
1168 | font-size: 0.9em;
|
---|
1169 | font-family: Helvetica, Arial, sans-serif;
|
---|
1170 | }
|
---|
1171 |
|
---|
1172 | h1.shortname {
|
---|
1173 | color: #f60;
|
---|
1174 | font-size: 1.5em;
|
---|
1175 | margin: 0;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | h1.version {
|
---|
1179 | color: #f60;
|
---|
1180 | font-size: 1.5em;
|
---|
1181 | margin: 0;
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | h1.title {
|
---|
1185 | margin-top: 0;
|
---|
1186 | color: #f60;
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | h1.first {
|
---|
1190 | margin-top: 0;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | h1, h2, h3, h4, h5, h6 {
|
---|
1194 | position: relative;
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | h1 .secnum {
|
---|
1198 | text-decoration: none;
|
---|
1199 | margin-right: 10px;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | h1 span.title {
|
---|
1203 | order: 2;
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 |
|
---|
1207 | h1 { font-size: 2.67em; margin-top: 2em; margin-bottom: 0; line-height: 1em;}
|
---|
1208 | h2 { font-size: 2em; }
|
---|
1209 | h3 { font-size: 1.56em; }
|
---|
1210 | h4 { font-size: 1.25em; }
|
---|
1211 | h5 { font-size: 1.11em; }
|
---|
1212 | h6 { font-size: 1em; }
|
---|
1213 |
|
---|
1214 | h1:hover span.utils {
|
---|
1215 | display: block;
|
---|
1216 | }
|
---|
1217 |
|
---|
1218 | span.utils {
|
---|
1219 | font-size: 18px;
|
---|
1220 | line-height: 18px;
|
---|
1221 | display: none;
|
---|
1222 | position: absolute;
|
---|
1223 | top: 100%;
|
---|
1224 | left: 0;
|
---|
1225 | right: 0;
|
---|
1226 | font-weight: normal;
|
---|
1227 | }
|
---|
1228 |
|
---|
1229 | span.utils:before {
|
---|
1230 | content: "⤷";
|
---|
1231 | display: inline-block;
|
---|
1232 | padding: 0 5px;
|
---|
1233 | }
|
---|
1234 |
|
---|
1235 | span.utils > * {
|
---|
1236 | display: inline-block;
|
---|
1237 | margin-right: 20px;
|
---|
1238 | }
|
---|
1239 |
|
---|
1240 | h1 span.utils span.anchor a,
|
---|
1241 | h2 span.utils span.anchor a,
|
---|
1242 | h3 span.utils span.anchor a,
|
---|
1243 | h4 span.utils span.anchor a,
|
---|
1244 | h5 span.utils span.anchor a,
|
---|
1245 | h6 span.utils span.anchor a {
|
---|
1246 | text-decoration: none;
|
---|
1247 | font-variant: small-caps;
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | h1 span.utils span.anchor a:hover,
|
---|
1251 | h2 span.utils span.anchor a:hover,
|
---|
1252 | h3 span.utils span.anchor a:hover,
|
---|
1253 | h4 span.utils span.anchor a:hover,
|
---|
1254 | h5 span.utils span.anchor a:hover,
|
---|
1255 | h6 span.utils span.anchor a:hover {
|
---|
1256 | color: #333;
|
---|
1257 | }
|
---|
1258 |
|
---|
1259 | emu-intro h1, emu-clause h1, emu-annex h1 { font-size: 2em; }
|
---|
1260 | emu-intro h2, emu-clause h2, emu-annex h2 { font-size: 1.56em; }
|
---|
1261 | emu-intro h3, emu-clause h3, emu-annex h3 { font-size: 1.25em; }
|
---|
1262 | emu-intro h4, emu-clause h4, emu-annex h4 { font-size: 1.11em; }
|
---|
1263 | emu-intro h5, emu-clause h5, emu-annex h5 { font-size: 1em; }
|
---|
1264 | emu-intro h6, emu-clause h6, emu-annex h6 { font-size: 0.9em; }
|
---|
1265 | emu-intro emu-intro h1, emu-clause emu-clause h1, emu-annex emu-annex h1 { font-size: 1.56em; }
|
---|
1266 | emu-intro emu-intro h2, emu-clause emu-clause h2, emu-annex emu-annex h2 { font-size: 1.25em; }
|
---|
1267 | emu-intro emu-intro h3, emu-clause emu-clause h3, emu-annex emu-annex h3 { font-size: 1.11em; }
|
---|
1268 | emu-intro emu-intro h4, emu-clause emu-clause h4, emu-annex emu-annex h4 { font-size: 1em; }
|
---|
1269 | emu-intro emu-intro h5, emu-clause emu-clause h5, emu-annex emu-annex h5 { font-size: 0.9em; }
|
---|
1270 | emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex h1 { font-size: 1.25em; }
|
---|
1271 | emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex h2 { font-size: 1.11em; }
|
---|
1272 | emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex h3 { font-size: 1em; }
|
---|
1273 | emu-intro emu-intro emu-intro h4, emu-clause emu-clause emu-clause h4, emu-annex emu-annex emu-annex h4 { font-size: 0.9em; }
|
---|
1274 | emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1.11em; }
|
---|
1275 | emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex h2 { font-size: 1em; }
|
---|
1276 | emu-intro emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex emu-annex h3 { font-size: 0.9em; }
|
---|
1277 | emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1em; }
|
---|
1278 | emu-intro emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex emu-annex h2 { font-size: 0.9em; }
|
---|
1279 | emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 0.9em }
|
---|
1280 |
|
---|
1281 | emu-clause, emu-intro, emu-annex {
|
---|
1282 | display: block;
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 | /* Figures and tables */
|
---|
1286 | figure { display: block; margin: 1em 0 3em 0; }
|
---|
1287 | figure object { display: block; margin: 0 auto; }
|
---|
1288 | figure table.real-table { margin: 0 auto; }
|
---|
1289 | figure figcaption {
|
---|
1290 | display: block;
|
---|
1291 | color: #555555;
|
---|
1292 | font-weight: bold;
|
---|
1293 | text-align: center;
|
---|
1294 | }
|
---|
1295 |
|
---|
1296 | emu-table table {
|
---|
1297 | margin: 0 auto;
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 | emu-table table, table.real-table {
|
---|
1301 | border-collapse: collapse;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | emu-table td, emu-table th, table.real-table td, table.real-table th {
|
---|
1305 | border: 1px solid black;
|
---|
1306 | padding: 0.4em;
|
---|
1307 | vertical-align: baseline;
|
---|
1308 | }
|
---|
1309 | emu-table th, emu-table thead td, table.real-table th {
|
---|
1310 | background-color: #eeeeee;
|
---|
1311 | }
|
---|
1312 |
|
---|
1313 | /* Note: the left content edges of table.lightweight-table >tbody >tr >td
|
---|
1314 | and div.display line up. */
|
---|
1315 | table.lightweight-table {
|
---|
1316 | border-collapse: collapse;
|
---|
1317 | margin: 0 0 0 1.5em;
|
---|
1318 | }
|
---|
1319 | table.lightweight-table td, table.lightweight-table th {
|
---|
1320 | border: none;
|
---|
1321 | padding: 0 0.5em;
|
---|
1322 | vertical-align: baseline;
|
---|
1323 | }
|
---|
1324 |
|
---|
1325 | /* diff styles */
|
---|
1326 | ins {
|
---|
1327 | background-color: #e0f8e0;
|
---|
1328 | text-decoration: none;
|
---|
1329 | border-bottom: 1px solid #396;
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | del {
|
---|
1333 | background-color: #fee;
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | ins.block, del.block,
|
---|
1337 | emu-production > ins, emu-production > del,
|
---|
1338 | emu-grammar > ins, emu-grammar > del {
|
---|
1339 | display: block;
|
---|
1340 | }
|
---|
1341 | emu-rhs > ins, emu-rhs > del {
|
---|
1342 | display: inline;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | tr.ins > td > ins {
|
---|
1346 | border-bottom: none;
|
---|
1347 | }
|
---|
1348 |
|
---|
1349 | tr.ins > td {
|
---|
1350 | background-color: #e0f8e0;
|
---|
1351 | }
|
---|
1352 |
|
---|
1353 | tr.del > td {
|
---|
1354 | background-color: #fee;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | /* Menu Styles */
|
---|
1358 | #menu-toggle {
|
---|
1359 | font-size: 2em;
|
---|
1360 |
|
---|
1361 | position: fixed;
|
---|
1362 | top: 0;
|
---|
1363 | left: 0;
|
---|
1364 | width: 1.5em;
|
---|
1365 | height: 1.5em;
|
---|
1366 | z-index: 3;
|
---|
1367 | visibility: hidden;
|
---|
1368 | color: #1567a2;
|
---|
1369 | background-color: #fff;
|
---|
1370 |
|
---|
1371 | line-height: 1.5em;
|
---|
1372 | text-align: center;
|
---|
1373 | -webkit-touch-callout: none;
|
---|
1374 | -webkit-user-select: none;
|
---|
1375 | -khtml-user-select: none;
|
---|
1376 | -moz-user-select: none;
|
---|
1377 | -ms-user-select: none;
|
---|
1378 | user-select: none;;
|
---|
1379 |
|
---|
1380 | cursor: pointer;
|
---|
1381 | }
|
---|
1382 |
|
---|
1383 | #menu {
|
---|
1384 | display: flex;
|
---|
1385 | flex-direction: column;
|
---|
1386 | width: 33%; height: 100vh;
|
---|
1387 | max-width: 500px;
|
---|
1388 | box-sizing: border-box;
|
---|
1389 | background-color: #ddd;
|
---|
1390 | overflow: hidden;
|
---|
1391 | transition: opacity 0.1s linear;
|
---|
1392 | padding: 0 5px;
|
---|
1393 | position: fixed;
|
---|
1394 | left: 0; top: 0;
|
---|
1395 | border-right: 2px solid #bbb;
|
---|
1396 |
|
---|
1397 | z-index: 2;
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 | #menu-spacer {
|
---|
1401 | flex-basis: 33%;
|
---|
1402 | max-width: 500px;
|
---|
1403 | flex-grow: 0;
|
---|
1404 | flex-shrink: 0;
|
---|
1405 | }
|
---|
1406 |
|
---|
1407 | #menu a {
|
---|
1408 | color: #1567a2;
|
---|
1409 | }
|
---|
1410 |
|
---|
1411 | #menu.active {
|
---|
1412 | display: flex;
|
---|
1413 | opacity: 1;
|
---|
1414 | z-index: 2;
|
---|
1415 | }
|
---|
1416 |
|
---|
1417 | #menu-pins {
|
---|
1418 | flex-grow: 1;
|
---|
1419 | display: none;
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | #menu-pins.active {
|
---|
1423 | display: block;
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | #menu-pins-list {
|
---|
1427 | margin: 0;
|
---|
1428 | padding: 0;
|
---|
1429 | counter-reset: pins-counter;
|
---|
1430 | }
|
---|
1431 |
|
---|
1432 | #menu-pins-list > li:before {
|
---|
1433 | content: counter(pins-counter);
|
---|
1434 | counter-increment: pins-counter;
|
---|
1435 | display: inline-block;
|
---|
1436 | width: 25px;
|
---|
1437 | text-align: center;
|
---|
1438 | border: 1px solid #bbb;
|
---|
1439 | padding: 2px;
|
---|
1440 | margin: 4px;
|
---|
1441 | box-sizing: border-box;
|
---|
1442 | line-height: 1em;
|
---|
1443 | background-color: #ccc;
|
---|
1444 | border-radius: 4px;
|
---|
1445 | }
|
---|
1446 | #menu-toc > ol {
|
---|
1447 | padding: 0;
|
---|
1448 | flex-grow: 1;
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | #menu-toc > ol li {
|
---|
1452 | padding: 0;
|
---|
1453 | }
|
---|
1454 |
|
---|
1455 | #menu-toc > ol , #menu-toc > ol ol {
|
---|
1456 | list-style-type: none;
|
---|
1457 | margin: 0;
|
---|
1458 | padding: 0;
|
---|
1459 | }
|
---|
1460 |
|
---|
1461 | #menu-toc > ol ol {
|
---|
1462 | padding-left: 0.75em;
|
---|
1463 | }
|
---|
1464 |
|
---|
1465 | #menu-toc li {
|
---|
1466 | text-overflow: ellipsis;
|
---|
1467 | overflow: hidden;
|
---|
1468 | white-space: nowrap;
|
---|
1469 | }
|
---|
1470 |
|
---|
1471 | #menu-toc .item-toggle {
|
---|
1472 | display: inline-block;
|
---|
1473 | transform: rotate(-45deg) translate(-5px, -5px);
|
---|
1474 | transition: transform 0.1s ease;
|
---|
1475 | text-align: center;
|
---|
1476 | width: 20px;
|
---|
1477 |
|
---|
1478 | color: #aab;
|
---|
1479 |
|
---|
1480 | -webkit-touch-callout: none;
|
---|
1481 | -webkit-user-select: none;
|
---|
1482 | -khtml-user-select: none;
|
---|
1483 | -moz-user-select: none;
|
---|
1484 | -ms-user-select: none;
|
---|
1485 | user-select: none;;
|
---|
1486 |
|
---|
1487 | cursor: pointer;
|
---|
1488 | }
|
---|
1489 |
|
---|
1490 | #menu-toc .item-toggle-none {
|
---|
1491 | display: inline-block;
|
---|
1492 | width: 20px;
|
---|
1493 | }
|
---|
1494 |
|
---|
1495 | #menu-toc li.active > .item-toggle {
|
---|
1496 | transform: rotate(45deg) translate(-5px, -5px);
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 | #menu-toc li > ol {
|
---|
1500 | display: none;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | #menu-toc li.active > ol {
|
---|
1504 | display: block;
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | #menu-toc li.revealed > a {
|
---|
1508 | background-color: #bbb;
|
---|
1509 | font-weight: bold;
|
---|
1510 | /*
|
---|
1511 | background-color: #222;
|
---|
1512 | color: #c6d8e4;
|
---|
1513 | */
|
---|
1514 | }
|
---|
1515 |
|
---|
1516 | #menu-toc li.revealed-leaf> a {
|
---|
1517 | color: #206ca7;
|
---|
1518 | /*
|
---|
1519 | background-color: #222;
|
---|
1520 | color: #c6d8e4;
|
---|
1521 | */
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | #menu-toc li.revealed > .item-toggle {
|
---|
1525 | transform: rotate(45deg) translate(-5px, -5px);
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | #menu-toc li.revealed > ol {
|
---|
1529 | display: block;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | #menu-toc li > a {
|
---|
1533 | padding: 2px 5px;
|
---|
1534 | }
|
---|
1535 |
|
---|
1536 | #menu > * {
|
---|
1537 | margin-bottom: 5px;
|
---|
1538 | }
|
---|
1539 |
|
---|
1540 | .menu-pane-header {
|
---|
1541 | padding: 0 5px;
|
---|
1542 | text-transform: uppercase;
|
---|
1543 | background-color: #aaa;
|
---|
1544 | color: #335;
|
---|
1545 | font-weight: bold;
|
---|
1546 | letter-spacing: 2px;
|
---|
1547 | flex-grow: 0;
|
---|
1548 | flex-shrink: 0;
|
---|
1549 | font-size: 0.8em;
|
---|
1550 | }
|
---|
1551 |
|
---|
1552 | #menu-toc {
|
---|
1553 | display: flex;
|
---|
1554 | flex-direction: column;
|
---|
1555 | width: 100%;
|
---|
1556 | overflow: hidden;
|
---|
1557 | flex-grow: 1;
|
---|
1558 | }
|
---|
1559 |
|
---|
1560 | #menu-toc ol.toc {
|
---|
1561 | overflow-x: hidden;
|
---|
1562 | overflow-y: auto;
|
---|
1563 | }
|
---|
1564 |
|
---|
1565 | #menu-search {
|
---|
1566 | position: relative;
|
---|
1567 | flex-grow: 0;
|
---|
1568 | flex-shrink: 0;
|
---|
1569 | width: 100%;
|
---|
1570 |
|
---|
1571 | display: flex;
|
---|
1572 | flex-direction: column;
|
---|
1573 |
|
---|
1574 | max-height: 300px;
|
---|
1575 | }
|
---|
1576 |
|
---|
1577 | #menu-trace-list {
|
---|
1578 | display: none;
|
---|
1579 | }
|
---|
1580 |
|
---|
1581 | #menu-search-box {
|
---|
1582 | box-sizing: border-box;
|
---|
1583 | display: block;
|
---|
1584 | width: 100%;
|
---|
1585 | margin: 5px 0 0 0;
|
---|
1586 | font-size: 1em;
|
---|
1587 | padding: 2px;
|
---|
1588 | background-color: #bbb;
|
---|
1589 | border: 1px solid #999;
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 | #menu-search-results {
|
---|
1593 | overflow-x: hidden;
|
---|
1594 | overflow-y: auto;
|
---|
1595 | }
|
---|
1596 |
|
---|
1597 | li.menu-search-result-clause:before {
|
---|
1598 | content: 'clause';
|
---|
1599 | width: 40px;
|
---|
1600 | display: inline-block;
|
---|
1601 | text-align: right;
|
---|
1602 | padding-right: 1ex;
|
---|
1603 | color: #666;
|
---|
1604 | font-size: 75%;
|
---|
1605 | }
|
---|
1606 | li.menu-search-result-op:before {
|
---|
1607 | content: 'op';
|
---|
1608 | width: 40px;
|
---|
1609 | display: inline-block;
|
---|
1610 | text-align: right;
|
---|
1611 | padding-right: 1ex;
|
---|
1612 | color: #666;
|
---|
1613 | font-size: 75%;
|
---|
1614 | }
|
---|
1615 |
|
---|
1616 | li.menu-search-result-prod:before {
|
---|
1617 | content: 'prod';
|
---|
1618 | width: 40px;
|
---|
1619 | display: inline-block;
|
---|
1620 | text-align: right;
|
---|
1621 | padding-right: 1ex;
|
---|
1622 | color: #666;
|
---|
1623 | font-size: 75%
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 |
|
---|
1627 | li.menu-search-result-term:before {
|
---|
1628 | content: 'term';
|
---|
1629 | width: 40px;
|
---|
1630 | display: inline-block;
|
---|
1631 | text-align: right;
|
---|
1632 | padding-right: 1ex;
|
---|
1633 | color: #666;
|
---|
1634 | font-size: 75%
|
---|
1635 | }
|
---|
1636 |
|
---|
1637 | #menu-search-results ul {
|
---|
1638 | padding: 0 5px;
|
---|
1639 | margin: 0;
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 | #menu-search-results li {
|
---|
1643 | white-space: nowrap;
|
---|
1644 | text-overflow: ellipsis;
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 |
|
---|
1648 | #menu-trace-list {
|
---|
1649 | counter-reset: item;
|
---|
1650 | margin: 0 0 0 20px;
|
---|
1651 | padding: 0;
|
---|
1652 | }
|
---|
1653 | #menu-trace-list li {
|
---|
1654 | display: block;
|
---|
1655 | white-space: nowrap;
|
---|
1656 | }
|
---|
1657 |
|
---|
1658 | #menu-trace-list li .secnum:after {
|
---|
1659 | content: " ";
|
---|
1660 | }
|
---|
1661 | #menu-trace-list li:before {
|
---|
1662 | content: counter(item) " ";
|
---|
1663 | background-color: #222;
|
---|
1664 | counter-increment: item;
|
---|
1665 | color: #999;
|
---|
1666 | width: 20px;
|
---|
1667 | height: 20px;
|
---|
1668 | line-height: 20px;
|
---|
1669 | display: inline-block;
|
---|
1670 | text-align: center;
|
---|
1671 | margin: 2px 4px 2px 0;
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | @media (max-width: 1000px) {
|
---|
1675 | body {
|
---|
1676 | margin: 0;
|
---|
1677 | display: block;
|
---|
1678 | }
|
---|
1679 |
|
---|
1680 | #menu {
|
---|
1681 | display: none;
|
---|
1682 | padding-top: 3em;
|
---|
1683 | width: 450px;
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | #menu.active {
|
---|
1687 | position: fixed;
|
---|
1688 | height: 100%;
|
---|
1689 | left: 0;
|
---|
1690 | top: 0;
|
---|
1691 | right: 300px;
|
---|
1692 | }
|
---|
1693 |
|
---|
1694 | #menu-toggle {
|
---|
1695 | visibility: visible;
|
---|
1696 | }
|
---|
1697 |
|
---|
1698 | #spec-container {
|
---|
1699 | padding: 0 5px;
|
---|
1700 | }
|
---|
1701 |
|
---|
1702 | #references-pane-spacer {
|
---|
1703 | display: none;
|
---|
1704 | }
|
---|
1705 | }
|
---|
1706 |
|
---|
1707 | @media only screen and (max-width: 800px) {
|
---|
1708 | #menu {
|
---|
1709 | width: 100%;
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 | h1 .secnum:empty {
|
---|
1713 | margin: 0; padding: 0;
|
---|
1714 | }
|
---|
1715 | }
|
---|
1716 |
|
---|
1717 |
|
---|
1718 | /* Toolbox */
|
---|
1719 | .toolbox {
|
---|
1720 | position: absolute;
|
---|
1721 | background: #ddd;
|
---|
1722 | border: 1px solid #aaa;
|
---|
1723 | display: none;
|
---|
1724 | color: #eee;
|
---|
1725 | padding: 5px;
|
---|
1726 | border-radius: 3px;
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | .toolbox.active {
|
---|
1730 | display: inline-block;
|
---|
1731 | }
|
---|
1732 |
|
---|
1733 | .toolbox a {
|
---|
1734 | text-decoration: none;
|
---|
1735 | padding: 0 5px;
|
---|
1736 | }
|
---|
1737 |
|
---|
1738 | .toolbox a:hover {
|
---|
1739 | text-decoration: underline;
|
---|
1740 | }
|
---|
1741 |
|
---|
1742 | .toolbox:after, .toolbox:before {
|
---|
1743 | top: 100%;
|
---|
1744 | left: 15px;
|
---|
1745 | border: solid transparent;
|
---|
1746 | content: " ";
|
---|
1747 | height: 0;
|
---|
1748 | width: 0;
|
---|
1749 | position: absolute;
|
---|
1750 | pointer-events: none;
|
---|
1751 | }
|
---|
1752 |
|
---|
1753 | .toolbox:after {
|
---|
1754 | border-color: rgba(0, 0, 0, 0);
|
---|
1755 | border-top-color: #ddd;
|
---|
1756 | border-width: 10px;
|
---|
1757 | margin-left: -10px;
|
---|
1758 | }
|
---|
1759 | .toolbox:before {
|
---|
1760 | border-color: rgba(204, 204, 204, 0);
|
---|
1761 | border-top-color: #aaa;
|
---|
1762 | border-width: 12px;
|
---|
1763 | margin-left: -12px;
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | #references-pane-container {
|
---|
1767 | position: fixed;
|
---|
1768 | bottom: 0;
|
---|
1769 | left: 0;
|
---|
1770 | right: 0;
|
---|
1771 | height: 250px;
|
---|
1772 | display: none;
|
---|
1773 | background-color: #ddd;
|
---|
1774 | z-index: 1;
|
---|
1775 | }
|
---|
1776 |
|
---|
1777 | #references-pane-table-container {
|
---|
1778 | overflow-x: hidden;
|
---|
1779 | overflow-y: auto;
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 | #references-pane-spacer {
|
---|
1783 | flex-basis: 33%;
|
---|
1784 | max-width: 500px;
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | #references-pane {
|
---|
1788 | flex-grow: 1;
|
---|
1789 | overflow: hidden;
|
---|
1790 | display: flex;
|
---|
1791 | flex-direction: column;
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 | #references-pane-container.active {
|
---|
1795 | display: flex;
|
---|
1796 | }
|
---|
1797 |
|
---|
1798 | #references-pane-close:after {
|
---|
1799 | content: '✖';
|
---|
1800 | float: right;
|
---|
1801 | cursor: pointer;
|
---|
1802 | }
|
---|
1803 |
|
---|
1804 | #references-pane table tr td:first-child {
|
---|
1805 | text-align: right;
|
---|
1806 | padding-right: 5px;
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 | @media print {
|
---|
1810 | #menu-toggle {
|
---|
1811 | display: none;
|
---|
1812 | }
|
---|
1813 | }
|
---|
1814 | </style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#introduction" title="Metadata Proposal - ECMAScript">Metadata Proposal - ECMAScript</a></li><li><span class="item-toggle-none"></span><a href="#syntax" title="Syntax"><span class="secnum">1</span> Syntax</a></li><li><span class="item-toggle">◢</span><a href="#abstract-operations" title="Abstract Operations"><span class="secnum">2</span> Abstract Operations</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#operations-on-objects" title="Operations on Objects"><span class="secnum">2.1</span> Operations on Objects</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#getorcreatemetadatamap" title="GetOrCreateMetadataMap ( O, P, Create )"><span class="secnum">2.1.1</span> GetOrCreateMetadataMap ( O, P, Create )</a></li></ol></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-and-exotic-objects-behaviors" title="Ordinary and Exotic Objects Behaviors"><span class="secnum">3</span> Ordinary and Exotic Objects Behaviors</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots" title="Ordinary Object Internal Methods and Internal Slots"><span class="secnum">3.1</span> Ordinary Object Internal Methods and Internal Slots</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-hasmetadata" title="[[HasMetadata]] ( MetadataKey, P )"><span class="secnum">3.1.1</span> [[HasMetadata]] ( MetadataKey, P )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinaryhasmetadata" title="OrdinaryHasMetadata ( MetadataKey, O, P )"><span class="secnum">3.1.1.1</span> OrdinaryHasMetadata ( MetadataKey, O, P )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-hasownmetadata" title="[[HasOwnMetadata]] ( MetadataKey, P )"><span class="secnum">3.1.2</span> [[HasOwnMetadata]] ( MetadataKey, P )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinaryhasownmetadata" title="OrdinaryHasOwnMetadata ( MetadataKey, O, P )"><span class="secnum">3.1.2.1</span> OrdinaryHasOwnMetadata ( MetadataKey, O, P )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-getmetadata" title="[[GetMetadata]] ( MetadataKey, P )"><span class="secnum">3.1.3</span> [[GetMetadata]] ( MetadataKey, P )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinarygetmetadata" title="OrdinaryGetMetadata ( MetadataKey, O, P )"><span class="secnum">3.1.3.1</span> OrdinaryGetMetadata ( MetadataKey, O, P )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-getownmetadata" title="[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )"><span class="secnum">3.1.4</span> [[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinarygetownmetadata" title="OrdinaryGetOwnMetadata ( MetadataKey, O, P )"><span class="secnum">3.1.4.1</span> OrdinaryGetOwnMetadata ( MetadataKey, O, P )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-defineownmetadata" title="[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )"><span class="secnum">3.1.5</span> [[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinarydefineownmetadata" title="OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )"><span class="secnum">3.1.5.1</span> OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-metadatakeys" title="[[MetadataKeys]] ( P )"><span class="secnum">3.1.6</span> [[MetadataKeys]] ( P )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinarymetadatakeys" title="OrdinaryMetadataKeys ( O, P )"><span class="secnum">3.1.6.1</span> OrdinaryMetadataKeys ( O, P )</a></li></ol></li><li><span class="item-toggle">◢</span><a href="#ordinary-object-internal-methods-and-internal-slots-ownmetadatakeys" title="[[OwnMetadataKeys]] ( P )"><span class="secnum">3.1.7</span> [[OwnMetadataKeys]] ( P )</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#ordinaryownmetadatakeys" title="OrdinaryOwnMetadataKeys ( O, P )"><span class="secnum">3.1.7.1</span> OrdinaryOwnMetadataKeys ( O, P )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#ordinary-object-internal-methods-and-internal-slots-deletemetadata" title="[[DeleteMetadata]]( MetadataKey, P )"><span class="secnum">3.1.8</span> [[DeleteMetadata]]( MetadataKey, P )</a></li></ol></li></ol></li><li><span class="item-toggle">◢</span><a href="#reflection" title="Reflection"><span class="secnum">4</span> Reflection</a><ol class="toc"><li><span class="item-toggle">◢</span><a href="#reflect" title="The Reflect Object"><span class="secnum">4.1</span> The Reflect Object</a><ol class="toc"><li><span class="item-toggle-none"></span><a href="#reflect-metadatadecoratorfunctions" title="Metadata Decorator Functions"><span class="secnum">4.1.1</span> Metadata Decorator Functions</a></li><li><span class="item-toggle-none"></span><a href="#reflect.metadata" title="Reflect.metadata ( metadataKey, metadataValue )"><span class="secnum">4.1.2</span> Reflect.metadata ( metadataKey, metadataValue )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.definemetadata" title="Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )"><span class="secnum">4.1.3</span> Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.hasmetadata" title="Reflect.hasMetadata ( metadataKey, target [, propertyKey] )"><span class="secnum">4.1.4</span> Reflect.hasMetadata ( metadataKey, target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.hasownmetadata" title="Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )"><span class="secnum">4.1.5</span> Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.getmetadata" title="Reflect.getMetadata ( metadataKey, target [, propertyKey] )"><span class="secnum">4.1.6</span> Reflect.getMetadata ( metadataKey, target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.getownmetadata" title="Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )"><span class="secnum">4.1.7</span> Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.getmetadatakeys" title="Reflect.getMetadataKeys ( target [, propertyKey] )"><span class="secnum">4.1.8</span> Reflect.getMetadataKeys ( target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.getownmetadatakeys" title="Reflect.getOwnMetadataKeys ( target [, propertyKey] )"><span class="secnum">4.1.9</span> Reflect.getOwnMetadataKeys ( target [, propertyKey] )</a></li><li><span class="item-toggle-none"></span><a href="#reflect.deletemetadata" title="Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )"><span class="secnum">4.1.10</span> Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )</a></li></ol></li></ol></li></ol></div></div><div id="spec-container">
|
---|
1815 |
|
---|
1816 | <emu-intro id="introduction">
|
---|
1817 | <h1 class="first">Metadata Proposal - ECMAScript</h1>
|
---|
1818 | <emu-note><span class="note">Note</span><div class="note-contents">A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></div></emu-note>
|
---|
1819 | <p>Proposal to add Metadata to ECMAScript.</p>
|
---|
1820 | </emu-intro>
|
---|
1821 |
|
---|
1822 | <emu-clause id="syntax">
|
---|
1823 | <h1><span class="secnum">1</span>Syntax</h1>
|
---|
1824 | <emu-note><span class="note">Note</span><div class="note-contents">This section is non-normative.</div></emu-note>
|
---|
1825 | <pre><code class="javascript hljs"><span class="hljs-comment">// define metadata on an object or property</span>
|
---|
1826 | <span class="hljs-built_in">Reflect</span>.defineMetadata(metadataKey, metadataValue, target);
|
---|
1827 | <span class="hljs-built_in">Reflect</span>.defineMetadata(metadataKey, metadataValue, target, propertyKey);
|
---|
1828 |
|
---|
1829 | <span class="hljs-comment">// check for presence of a metadata key on the prototype chain of an object or property</span>
|
---|
1830 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasMetadata(metadataKey, target);
|
---|
1831 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasMetadata(metadataKey, target, propertyKey);
|
---|
1832 |
|
---|
1833 | <span class="hljs-comment">// check for presence of an own metadata key of an object or property</span>
|
---|
1834 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasOwnMetadata(metadataKey, target);
|
---|
1835 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasOwnMetadata(metadataKey, target, propertyKey);
|
---|
1836 |
|
---|
1837 | <span class="hljs-comment">// get metadata value of a metadata key on the prototype chain of an object or property</span>
|
---|
1838 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadata(metadataKey, target);
|
---|
1839 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadata(metadataKey, target, propertyKey);
|
---|
1840 |
|
---|
1841 | <span class="hljs-comment">// get metadata value of an own metadata key of an object or property</span>
|
---|
1842 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadata(metadataKey, target);
|
---|
1843 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadata(metadataKey, target, propertyKey);
|
---|
1844 |
|
---|
1845 | <span class="hljs-comment">// get all metadata keys on the prototype chain of an object or property</span>
|
---|
1846 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadataKeys(target);
|
---|
1847 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadataKeys(target, propertyKey);
|
---|
1848 |
|
---|
1849 | <span class="hljs-comment">// get all own metadata keys of an object or property</span>
|
---|
1850 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadataKeys(target);
|
---|
1851 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadataKeys(target, propertyKey);
|
---|
1852 |
|
---|
1853 | <span class="hljs-comment">// delete metadata from an object or property</span>
|
---|
1854 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.deleteMetadata(metadataKey, target);
|
---|
1855 | <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.deleteMetadata(metadataKey, target, propertyKey);
|
---|
1856 |
|
---|
1857 | <span class="hljs-comment">// apply metadata via a decorator to a constructor</span>
|
---|
1858 | @<span class="hljs-built_in">Reflect</span>.metadata(metadataKey, metadataValue)
|
---|
1859 | <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">C</span> </span>{
|
---|
1860 | <span class="hljs-comment">// apply metadata via a decorator to a method (property)</span>
|
---|
1861 | @<span class="hljs-built_in">Reflect</span>.metadata(metadataKey, metadataValue)
|
---|
1862 | method() {
|
---|
1863 | }
|
---|
1864 | }
|
---|
1865 |
|
---|
1866 | <span class="hljs-comment">// Design-time type annotations</span>
|
---|
1867 | <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Type</span>(<span class="hljs-params">type</span>) </span>{ <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.metadata(<span class="hljs-string">"design:type"</span>, type); }
|
---|
1868 | <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ParamTypes</span>(<span class="hljs-params">...types</span>) </span>{ <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.metadata(<span class="hljs-string">"design:paramtypes"</span>, types); }
|
---|
1869 | <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">ReturnType</span>(<span class="hljs-params">type</span>) </span>{ <span class="hljs-keyword">return</span> <span class="hljs-built_in">Reflect</span>.metadata(<span class="hljs-string">"design:returntype"</span>, type); }
|
---|
1870 |
|
---|
1871 | <span class="hljs-comment">// Decorator application</span>
|
---|
1872 | @ParamTypes(<span class="hljs-built_in">String</span>, <span class="hljs-built_in">Number</span>)
|
---|
1873 | <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">C</span> </span>{
|
---|
1874 | <span class="hljs-keyword">constructor</span>(text, i) {
|
---|
1875 | }
|
---|
1876 |
|
---|
1877 | @Type(<span class="hljs-built_in">String</span>)
|
---|
1878 | get name() { <span class="hljs-keyword">return</span> <span class="hljs-string">"text"</span>; }
|
---|
1879 |
|
---|
1880 | @Type(<span class="hljs-built_in">Function</span>)
|
---|
1881 | @ParamTypes(<span class="hljs-built_in">Number</span>, <span class="hljs-built_in">Number</span>)
|
---|
1882 | @ReturnType(<span class="hljs-built_in">Number</span>)
|
---|
1883 | add(x, y) {
|
---|
1884 | <span class="hljs-keyword">return</span> x + y;
|
---|
1885 | }
|
---|
1886 | }
|
---|
1887 |
|
---|
1888 | <span class="hljs-comment">// Metadata introspection</span>
|
---|
1889 | <span class="hljs-keyword">let</span> obj = <span class="hljs-keyword">new</span> C(<span class="hljs-string">"a"</span>, <span class="hljs-number">1</span>);
|
---|
1890 | <span class="hljs-keyword">let</span> paramTypes = <span class="hljs-built_in">Reflect</span>.getMetadata(<span class="hljs-string">"design:paramtypes"</span>, inst, <span class="hljs-string">"add"</span>); <span class="hljs-comment">// [Number, Number]</span></code></pre>
|
---|
1891 | </emu-clause>
|
---|
1892 |
|
---|
1893 | <emu-clause id="abstract-operations">
|
---|
1894 | <h1><span class="secnum">2</span>Abstract Operations</h1>
|
---|
1895 | <emu-clause id="operations-on-objects">
|
---|
1896 | <h1><span class="secnum">2.1</span>Operations on Objects</h1>
|
---|
1897 | <emu-clause id="getorcreatemetadatamap" aoid="GetOrCreateMetadataMap">
|
---|
1898 | <h1><span class="secnum">2.1.1</span>GetOrCreateMetadataMap ( O, P, Create )</h1>
|
---|
1899 | <p>When the abstract operation GetOrCreateMetadataMap is called with Object <var>O</var>, property key <var>P</var>, and Boolean <var>Create</var> the following steps are taken:</p>
|
---|
1900 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_0"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>targetMetadata</var> be the value of <var>O</var>'s [[Metadata]] internal slot.</li><li>If <var>targetMetadata</var> is <emu-val>undefined</emu-val>, then<ol><li>If <var>Create</var> is <emu-val>false</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Set <var>targetMetadata</var> to be a newly created <emu-val>Map</emu-val> object.</li><li>Set the [[Metadata]] internal slot of <var>O</var> to <var>targetMetadata</var>.</li></ol></li><li>Let <var>metadataMap</var> be ? <emu-xref aoid="Invoke" id="_ref_1"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>targetMetadata</var>, <code>"get"</code>, <var>P</var>).</li><li>If <var>metadataMap</var> is <emu-val>undefined</emu-val>, then<ol><li>If <var>Create</var> is <emu-val>false</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Set <var>metadataMap</var> to be a newly created <emu-val>Map</emu-val> object.</li><li>Perform ? <emu-xref aoid="Invoke" id="_ref_2"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>targetMetadata</var>, <code>"set"</code>, <var>P</var>, <var>metadataMap</var>).</li></ol></li><li>Return <var>metadataMap</var>.
|
---|
1901 | </li></ol></emu-alg>
|
---|
1902 | </emu-clause>
|
---|
1903 | </emu-clause>
|
---|
1904 | </emu-clause>
|
---|
1905 |
|
---|
1906 | <emu-clause id="ordinary-and-exotic-objects-behaviors">
|
---|
1907 | <h1><span class="secnum">3</span>Ordinary and Exotic Objects Behaviors</h1>
|
---|
1908 |
|
---|
1909 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots">
|
---|
1910 | <h1><span class="secnum">3.1</span>Ordinary Object Internal Methods and Internal Slots</h1>
|
---|
1911 | <p>All ordinary objects have an internal slot called [[Metadata]]. The value of this internal slot is either <emu-val>null</emu-val> or a <emu-val>Map</emu-val> object and is used for storing metadata for an object.</p>
|
---|
1912 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-hasmetadata">
|
---|
1913 | <h1><span class="secnum">3.1.1</span>[[HasMetadata]] ( MetadataKey, P )</h1>
|
---|
1914 | <p>When the [[HasMetadata]] internal method of <var>O</var> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
---|
1915 | <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryHasMetadata" id="_ref_3"><a href="#ordinaryhasmetadata">OrdinaryHasMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
|
---|
1916 | </li></ol></emu-alg>
|
---|
1917 | <emu-clause id="ordinaryhasmetadata" aoid="OrdinaryHasMetadata">
|
---|
1918 | <h1><span class="secnum">3.1.1.1</span>OrdinaryHasMetadata ( MetadataKey, O, P )</h1>
|
---|
1919 | <p>When the abstract operation OrdinaryHasMetadata is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
---|
1920 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_4"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>hasOwn</var> be ? <emu-xref aoid="OrdinaryHasOwnMetadata" id="_ref_5"><a href="#ordinaryhasownmetadata">OrdinaryHasOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).</li><li>If <var>hasOwn</var> is <emu-val>true</emu-val>, return <emu-val>true</emu-val>.</li><li>Let <var>parent</var> be ? <var>O</var>.[[GetPrototypeOf]]().</li><li>If <var>parent</var> is not <emu-val>null</emu-val>, Return ? <var>parent</var>.[[HasMetadata]](<var>MetadataKey</var>, <var>P</var>).</li><li>Return <emu-val>false</emu-val>.
|
---|
1921 | </li></ol></emu-alg>
|
---|
1922 | </emu-clause>
|
---|
1923 | </emu-clause>
|
---|
1924 |
|
---|
1925 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-hasownmetadata">
|
---|
1926 | <h1><span class="secnum">3.1.2</span>[[HasOwnMetadata]] ( MetadataKey, P )</h1>
|
---|
1927 | <p>When the [[HasOwnMetadata]] internal method of <var>O</var> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
---|
1928 | <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryHasOwnMetadata" id="_ref_6"><a href="#ordinaryhasownmetadata">OrdinaryHasOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
|
---|
1929 | </li></ol></emu-alg>
|
---|
1930 | <emu-clause id="ordinaryhasownmetadata" aoid="OrdinaryHasOwnMetadata">
|
---|
1931 | <h1><span class="secnum">3.1.2.1</span>OrdinaryHasOwnMetadata ( MetadataKey, O, P )</h1>
|
---|
1932 | <p>When the abstract operation OrdinaryHasOwnMetadata is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
---|
1933 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_7"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>metadataMap</var> be ? <emu-xref aoid="GetOrCreateMetadataMap" id="_ref_8"><a href="#getorcreatemetadatamap">GetOrCreateMetadataMap</a></emu-xref>(<var>O</var>, <var>P</var>, <emu-val>false</emu-val>).</li><li>If <var>metadataMap</var> is <emu-val>undefined</emu-val>, return <emu-val>false</emu-val>.</li><li>Return ? <emu-xref aoid="ToBoolean" id="_ref_9"><a href="https://tc39.github.io/ecma262/#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Invoke" id="_ref_10"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"has"</code>, <var>MetadataKey</var>)).
|
---|
1934 | </li></ol></emu-alg>
|
---|
1935 | </emu-clause>
|
---|
1936 | </emu-clause>
|
---|
1937 |
|
---|
1938 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-getmetadata">
|
---|
1939 | <h1><span class="secnum">3.1.3</span>[[GetMetadata]] ( MetadataKey, P )</h1>
|
---|
1940 | <p>When the [[GetMatadata]] internal method of <var>O</var> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
---|
1941 | <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryGetMetadata" id="_ref_11"><a href="#ordinarygetmetadata">OrdinaryGetMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
|
---|
1942 | </li></ol></emu-alg>
|
---|
1943 | <emu-clause id="ordinarygetmetadata" aoid="OrdinaryGetMetadata">
|
---|
1944 | <h1><span class="secnum">3.1.3.1</span>OrdinaryGetMetadata ( MetadataKey, O, P )</h1>
|
---|
1945 | <p>When the abstract operation OrdinaryGetMetadata is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
---|
1946 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_12"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>hasOwn</var> be ? <emu-xref aoid="OrdinaryHasOwnMetadata" id="_ref_13"><a href="#ordinaryhasownmetadata">OrdinaryHasOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).</li><li>If <var>hasOwn</var> is <emu-val>true</emu-val>, return ? <emu-xref aoid="OrdinaryGetOwnMetadata" id="_ref_14"><a href="#ordinarygetownmetadata">OrdinaryGetOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).</li><li>Let <var>parent</var> be ? <var>O</var>.[[GetPrototypeOf]]().</li><li>If <var>parent</var> is not <emu-val>null</emu-val>, return ? <var>parent</var>.[[GetMetadata]](<var>MetadataKey</var>, <var>P</var>).</li><li>Return <emu-val>undefined</emu-val>.
|
---|
1947 | </li></ol></emu-alg>
|
---|
1948 | </emu-clause>
|
---|
1949 | </emu-clause>
|
---|
1950 |
|
---|
1951 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-getownmetadata">
|
---|
1952 | <h1><span class="secnum">3.1.4</span>[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )</h1>
|
---|
1953 | <p>When the [[GetOwnMetadata]] internal method of <var>O</var> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
---|
1954 | <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryGetOwnMetadata" id="_ref_15"><a href="#ordinarygetownmetadata">OrdinaryGetOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
|
---|
1955 | </li></ol></emu-alg>
|
---|
1956 | <emu-clause id="ordinarygetownmetadata" aoid="OrdinaryGetOwnMetadata">
|
---|
1957 | <h1><span class="secnum">3.1.4.1</span>OrdinaryGetOwnMetadata ( MetadataKey, O, P )</h1>
|
---|
1958 | <p>When the abstract operation OrdinaryGetOwnMetadata is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
---|
1959 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_16"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>metadataMap</var> be ? <emu-xref aoid="GetOrCreateMetadataMap" id="_ref_17"><a href="#getorcreatemetadatamap">GetOrCreateMetadataMap</a></emu-xref>(<var>O</var>, <var>P</var>, <emu-val>false</emu-val>).</li><li>If <var>metadataMap</var> is <emu-val>undefined</emu-val>, return <emu-val>undefined</emu-val>.</li><li>Return ? <emu-xref aoid="Invoke" id="_ref_18"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"get"</code>, <var>MetadataKey</var>).
|
---|
1960 | </li></ol></emu-alg>
|
---|
1961 | </emu-clause>
|
---|
1962 | </emu-clause>
|
---|
1963 |
|
---|
1964 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-defineownmetadata">
|
---|
1965 | <h1><span class="secnum">3.1.5</span>[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )</h1>
|
---|
1966 | <p>When the [[DefineOwnMetadata]] internal method of <var>O</var> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var>, <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataValue</var>, and property key <var>P</var>, the following steps are taken:</p>
|
---|
1967 | <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryDefineOwnMetadata" id="_ref_19"><a href="#ordinarydefineownmetadata">OrdinaryDefineOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>MetadataValue</var>, <var>O</var>, <var>P</var>)
|
---|
1968 | </li></ol></emu-alg>
|
---|
1969 | <emu-clause id="ordinarydefineownmetadata" aoid="OrdinaryDefineOwnMetadata">
|
---|
1970 | <h1><span class="secnum">3.1.5.1</span>OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )</h1>
|
---|
1971 | <p>When the abstract operation <emu-xref aoid="OrdinaryDefineOwnProperty" id="_ref_20"><a href="https://tc39.github.io/ecma262/#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a></emu-xref> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var>, <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataValue</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
---|
1972 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_21"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>metadataMap</var> be ? <emu-xref aoid="GetOrCreateMetadataMap" id="_ref_22"><a href="#getorcreatemetadatamap">GetOrCreateMetadataMap</a></emu-xref>(<var>O</var>, <var>P</var>, <emu-val>true</emu-val>).</li><li>Return ? <emu-xref aoid="Invoke" id="_ref_23"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"set"</code>, <var>MetadataKey</var>, <var>MetadataValue</var>).
|
---|
1973 | </li></ol></emu-alg>
|
---|
1974 | </emu-clause>
|
---|
1975 | </emu-clause>
|
---|
1976 |
|
---|
1977 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-metadatakeys">
|
---|
1978 | <h1><span class="secnum">3.1.6</span>[[MetadataKeys]] ( P )</h1>
|
---|
1979 | <p>When the [[MetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
|
---|
1980 | <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryMetadataKeys" id="_ref_24"><a href="#ordinarymetadatakeys">OrdinaryMetadataKeys</a></emu-xref>(<var>O</var>, <var>P</var>).
|
---|
1981 | </li></ol></emu-alg>
|
---|
1982 | <emu-clause id="ordinarymetadatakeys" aoid="OrdinaryMetadataKeys">
|
---|
1983 | <h1><span class="secnum">3.1.6.1</span>OrdinaryMetadataKeys ( O, P )</h1>
|
---|
1984 | <p>When the abstract operation OrdinaryMetadataKeys is called with Object <var>O</var> and property key <var>P</var> the following steps are taken:</p>
|
---|
1985 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_25"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>ownKeys</var> be ? <emu-xref aoid="OrdinaryOwnMetadataKeys" id="_ref_26"><a href="#ordinaryownmetadatakeys">OrdinaryOwnMetadataKeys</a></emu-xref>(<var>O</var>, <var>P</var>).</li><li>Let <var>parent</var> be ? <var>O</var>.[[GetPrototypeOf]]().</li><li>If <var>parent</var> is <emu-val>null</emu-val>, then return <var>ownKeys</var>.</li><li>Let <var>parentKeys</var> be ? <var>O</var>.[[OrdinaryMetadataKeys]](<var>P</var>).</li><li>Let <var>ownKeysLen</var> = ? <emu-xref aoid="Get" id="_ref_27"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>ownKeys</var>, "length").</li><li>If <var>ownKeysLen</var> is <emu-val>0</emu-val>, return <var>parentKeys</var>.</li><li>Let <var>parentKeysLen</var> = ? <emu-xref aoid="Get" id="_ref_28"><a href="https://tc39.github.io/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>parentKeys</var>, "length").</li><li>If <var>parentKeysLen</var> is <emu-val>0</emu-val>, return <var>ownKeys</var>.</li><li>Let <var>set</var> be a newly created <emu-val>Set</emu-val> object.</li><li>Let <var>keys</var> be ? <emu-xref aoid="ArrayCreate" id="_ref_29"><a href="https://tc39.github.io/ecma262/#sec-arraycreate">ArrayCreate</a></emu-xref>(0).</li><li>Let <var>k</var> be <emu-val>0</emu-val>.</li><li>For each element <var>key</var> of <var>ownKeys</var><ol><li>Let <var>hasKey</var> be ? <emu-xref aoid="Invoke" id="_ref_30"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>set</var>, <code>"has"</code>, <var>key</var>).</li><li>If <var>hasKey</var> is <emu-val>false</emu-val>, then<ol><li>Let <var>Pk</var> be ! <emu-xref aoid="ToString" id="_ref_31"><a href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>k</var>).</li><li>Perform ? <emu-xref aoid="Invoke" id="_ref_32"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>set</var>, "add", <var>key</var>).</li><li>Let <var>defineStatus</var> be <emu-xref aoid="CreateDataProperty" id="_ref_33"><a href="https://tc39.github.io/ecma262/#sec-createdataproperty">CreateDataProperty</a></emu-xref>(<var>keys</var>, <var>Pk</var>, <var>key</var>).</li><li>Assert: <var>defineStatus</var> is <emu-val>true</emu-val>.</li><li>Increase <var>k</var> by <emu-val>1</emu-val>.</li></ol></li></ol></li><li>For each element <var>key</var> of <var>parentKeys</var><ol><li>Let <var>hasKey</var> be ? <emu-xref aoid="Invoke" id="_ref_34"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>set</var>, <code>"has"</code>, <var>key</var>).</li><li>If <var>hasKey</var> is <emu-val>false</emu-val>, then<ol><li>Let <var>Pk</var> be ! <emu-xref aoid="ToString" id="_ref_35"><a href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>k</var>).</li><li>Perform ? <emu-xref aoid="Invoke" id="_ref_36"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>set</var>, <code>"add"</code>, <var>key</var>).</li><li>Let <var>defineStatus</var> be <emu-xref aoid="CreateDataProperty" id="_ref_37"><a href="https://tc39.github.io/ecma262/#sec-createdataproperty">CreateDataProperty</a></emu-xref>(<var>keys</var>, <var>Pk</var>, <var>key</var>).</li><li>Assert: <var>defineStatus</var> is <emu-val>true</emu-val>.</li><li>Increase <var>k</var> by <emu-val>1</emu-val>.</li></ol></li></ol></li><li>Perform ? <emu-xref aoid="Set" id="_ref_38"><a href="https://tc39.github.io/ecma262/#sec-set-o-p-v-throw">Set</a></emu-xref>(<var>keys</var>, <code>"length"</code>, <var>k</var>).</li><li>return <var>keys</var>.
|
---|
1986 | </li></ol></emu-alg>
|
---|
1987 | </emu-clause>
|
---|
1988 | </emu-clause>
|
---|
1989 |
|
---|
1990 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-ownmetadatakeys">
|
---|
1991 | <h1><span class="secnum">3.1.7</span>[[OwnMetadataKeys]] ( P )</h1>
|
---|
1992 | <p>When the [[OwnMetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
|
---|
1993 | <emu-alg><ol><li>Return <emu-xref aoid="OrdinaryOwnMetadataKeys" id="_ref_39"><a href="#ordinaryownmetadatakeys">OrdinaryOwnMetadataKeys</a></emu-xref>(<var>O</var>, <var>P</var>).
|
---|
1994 | </li></ol></emu-alg>
|
---|
1995 | <emu-clause id="ordinaryownmetadatakeys" aoid="OrdinaryOwnMetadataKeys">
|
---|
1996 | <h1><span class="secnum">3.1.7.1</span>OrdinaryOwnMetadataKeys ( O, P )</h1>
|
---|
1997 | <p>When the abstract operation OrdinaryOwnMetadataKeys is called with Object <var>O</var> and property key <var>P</var> the following steps are taken:</p>
|
---|
1998 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_40"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>keys</var> be ? <emu-xref aoid="ArrayCreate" id="_ref_41"><a href="https://tc39.github.io/ecma262/#sec-arraycreate">ArrayCreate</a></emu-xref>(0).</li><li>Let <var>metadataMap</var> be ? <emu-xref aoid="GetOrCreateMetadataMap" id="_ref_42"><a href="#getorcreatemetadatamap">GetOrCreateMetadataMap</a></emu-xref>(<var>O</var>, <var>P</var>, <emu-val>false</emu-val>).</li><li>If <var>metadataMap</var> is <emu-val>undefined</emu-val>, return <var>keys</var>.</li><li>Let <var>keysObj</var> be ? <emu-xref aoid="Invoke" id="_ref_43"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"keys"</code>).</li><li>Let <var>iterator</var> be ? <emu-xref aoid="GetIterator" id="_ref_44"><a href="https://tc39.github.io/ecma262/#sec-getiterator">GetIterator</a></emu-xref>(<var>keysObj</var>).</li><li>Let <var>k</var> be <emu-val>0</emu-val>.</li><li>Repeat<ol><li>Let <var>Pk</var> be ! <emu-xref aoid="ToString" id="_ref_45"><a href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>k</var>).</li><li>Let <var>next</var> be ? <emu-xref aoid="IteratorStep" id="_ref_46"><a href="https://tc39.github.io/ecma262/#sec-iteratorstep">IteratorStep</a></emu-xref>(<var>iterator</var>).</li><li>If <var>next</var> is <emu-val>false</emu-val>, then<ol><li>Let <var>setStatus</var> be ? <emu-xref aoid="Set" id="_ref_47"><a href="https://tc39.github.io/ecma262/#sec-set-o-p-v-throw">Set</a></emu-xref>(<var>keys</var>, <code>"length"</code>, <var>k</var>, <var>true</var>).</li><li>Assert: <var>setStatus</var> is <emu-val>true</emu-val>.</li><li>Return <var>keys</var>.</li></ol></li><li>Let <var>nextValue</var> be ? <emu-xref aoid="IteratorValue" id="_ref_48"><a href="https://tc39.github.io/ecma262/#sec-iteratorvalue">IteratorValue</a></emu-xref>(<var>next</var>).</li><li>Let <var>defineStatus</var> be <emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_49"><a href="https://tc39.github.io/ecma262/#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>keys</var>, <var>Pk</var>, <var>nextValue</var>).</li><li>If <var>defineStatus</var> is an <emu-xref href="#sec-completion-record-specification-type"><a href="https://tc39.github.io/ecma262/#sec-completion-record-specification-type">abrupt completion</a></emu-xref>, return ? <emu-xref aoid="IteratorClose" id="_ref_50"><a href="https://tc39.github.io/ecma262/#sec-iteratorclose">IteratorClose</a></emu-xref>(<var>iterator</var>, <var>defineStatus</var>).</li><li>Increase <var>k</var> by <emu-val>1</emu-val>.
|
---|
1999 | </li></ol></li></ol></emu-alg>
|
---|
2000 | </emu-clause>
|
---|
2001 | </emu-clause>
|
---|
2002 |
|
---|
2003 | <emu-clause id="ordinary-object-internal-methods-and-internal-slots-deletemetadata">
|
---|
2004 | <h1><span class="secnum">3.1.8</span>[[DeleteMetadata]]( MetadataKey, P )</h1>
|
---|
2005 | <p>When the [[DeleteMetadata]] internal method of <var>O</var> is called with <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref> <var>MetadataKey</var> and property key <var>P</var> the following steps are taken:</p>
|
---|
2006 | <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey" id="_ref_51"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>P</var>) is <emu-val>true</emu-val>.</li><li>Let <var>metadataMap</var> be ? <emu-xref aoid="GetOrCreateMetadataMap" id="_ref_52"><a href="#getorcreatemetadatamap">GetOrCreateMetadataMap</a></emu-xref>(<var>O</var>, <var>P</var>, <emu-val>false</emu-val>).</li><li>If <var>metadataMap</var> is <emu-val>undefined</emu-val>, return <emu-val>false</emu-val>.</li><li>Return ? <emu-xref aoid="Invoke" id="_ref_53"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"delete"</code>, <var>MetadataKey</var>).
|
---|
2007 | </li></ol></emu-alg>
|
---|
2008 | </emu-clause>
|
---|
2009 | </emu-clause>
|
---|
2010 | </emu-clause>
|
---|
2011 |
|
---|
2012 | <emu-clause id="reflection">
|
---|
2013 | <h1><span class="secnum">4</span>Reflection</h1>
|
---|
2014 | <emu-clause id="reflect">
|
---|
2015 | <h1><span class="secnum">4.1</span>The Reflect Object</h1>
|
---|
2016 | <p>This section contains amendments to the Reflect object.</p>
|
---|
2017 | <emu-clause id="reflect-metadatadecoratorfunctions">
|
---|
2018 | <h1><span class="secnum">4.1.1</span>Metadata Decorator Functions</h1>
|
---|
2019 | <p>A metadata decorator function is an anonymous built-in function that has [[MetadataKey]] and [[MetadataValue]] internal slots.</p>
|
---|
2020 | <p>When a metadata decorator function <var>F</var> is called with arguments <var>target</var> and <var>key</var>, the following steps are taken:</p>
|
---|
2021 | <emu-alg><ol><li>Assert: <var>F</var> has a [[MetadataKey]] internal slot whose value is an <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>, or <emu-val>undefined</emu-val>.</li><li>Assert: <var>F</var> has a [[MetadataValue]] internal slot whose value is an <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>, or <emu-val>undefined</emu-val>.</li><li>If <emu-xref aoid="Type" id="_ref_54"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>If <var>key</var> is not <emu-val>undefined</emu-val> and <emu-xref aoid="IsPropertyKey" id="_ref_55"><a href="https://tc39.github.io/ecma262/#sec-ispropertykey">IsPropertyKey</a></emu-xref>(<var>key</var>) is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>metadataKey</var> be the value of <var>F</var>'s [[MetadataKey]] internal slot.</li><li>Let <var>metadataValue</var> be the value of <var>F</var>'s [[MetadataValue]] internal slot.</li><li>Perform ? <var>target</var>.[[DefineMetadata]](<var>metadataKey</var>, <var>metadataValue</var>, <var>target</var>, <var>key</var>).</li><li>Return <emu-val>undefined</emu-val>.
|
---|
2022 | </li></ol></emu-alg>
|
---|
2023 | </emu-clause>
|
---|
2024 |
|
---|
2025 | <emu-clause id="reflect.metadata">
|
---|
2026 | <h1><span class="secnum">4.1.2</span>Reflect.metadata ( metadataKey, metadataValue )</h1>
|
---|
2027 | <p>When the <code>metadata</code> function is called with arguments <var>metadataKey</var> and <var>metadataValue</var>, the following steps are taken:</p>
|
---|
2028 | <emu-alg><ol><li>Let <var>decorator</var> be a new built-in function object as defined in Metadata Decorator Functions.</li><li>Set the [[MetadataKey]] internal slot of <var>decorator</var> to <var>metadataKey</var>.</li><li>Set the [[MetadataValue]] internal slot of <var>decorator</var> to <var>metadataValue</var>.</li><li>Return <var>decorator</var>.
|
---|
2029 | </li></ol></emu-alg>
|
---|
2030 | </emu-clause>
|
---|
2031 |
|
---|
2032 | <emu-clause id="reflect.definemetadata">
|
---|
2033 | <h1><span class="secnum">4.1.3</span>Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )</h1>
|
---|
2034 | <p>When the <code>defineMetadata</code> function is called with arguments <var>metadataKey</var>, <var>metadataValue</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2035 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_56"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[DefineMetadata]](<var>metadataKey</var>, <var>metadataValue</var>, <var>propertyKey</var>).
|
---|
2036 | </li></ol></emu-alg>
|
---|
2037 | </emu-clause>
|
---|
2038 |
|
---|
2039 | <emu-clause id="reflect.hasmetadata">
|
---|
2040 | <h1><span class="secnum">4.1.4</span>Reflect.hasMetadata ( metadataKey, target [, propertyKey] )</h1>
|
---|
2041 | <p>When the <code>hasMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2042 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_57"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[HasMetadata]](<var>metadataKey</var>, <var>propertyKey</var>).
|
---|
2043 | </li></ol></emu-alg>
|
---|
2044 | </emu-clause>
|
---|
2045 |
|
---|
2046 | <emu-clause id="reflect.hasownmetadata">
|
---|
2047 | <h1><span class="secnum">4.1.5</span>Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )</h1>
|
---|
2048 | <p>When the <code>hasOwnMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2049 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_58"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[HasOwn]](<var>metadataKey</var>, <var>propertyKey</var>).
|
---|
2050 | </li></ol></emu-alg>
|
---|
2051 | </emu-clause>
|
---|
2052 |
|
---|
2053 | <emu-clause id="reflect.getmetadata">
|
---|
2054 | <h1><span class="secnum">4.1.6</span>Reflect.getMetadata ( metadataKey, target [, propertyKey] )</h1>
|
---|
2055 | <p>When the <code>getMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2056 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_59"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[GetMetadata]](<var>metadataKey</var>, <var>propertyKey</var>).
|
---|
2057 | </li></ol></emu-alg>
|
---|
2058 | </emu-clause>
|
---|
2059 |
|
---|
2060 | <emu-clause id="reflect.getownmetadata">
|
---|
2061 | <h1><span class="secnum">4.1.7</span>Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )</h1>
|
---|
2062 | <p>When the <code>getOwnMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2063 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_60"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[GetOwnMetadata]](<var>metadataKey</var>, <var>propertyKey</var>).
|
---|
2064 | </li></ol></emu-alg>
|
---|
2065 | </emu-clause>
|
---|
2066 |
|
---|
2067 | <emu-clause id="reflect.getmetadatakeys">
|
---|
2068 | <h1><span class="secnum">4.1.8</span>Reflect.getMetadataKeys ( target [, propertyKey] )</h1>
|
---|
2069 | <p>When the <code>getMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2070 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_61"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[GetMetadataKeys]](<var>propertyKey</var>).
|
---|
2071 | </li></ol></emu-alg>
|
---|
2072 | </emu-clause>
|
---|
2073 |
|
---|
2074 | <emu-clause id="reflect.getownmetadatakeys">
|
---|
2075 | <h1><span class="secnum">4.1.9</span>Reflect.getOwnMetadataKeys ( target [, propertyKey] )</h1>
|
---|
2076 | <p>When the <code>getOwnMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2077 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_62"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[GetOwnMetadataKeys]](<var>propertyKey</var>).
|
---|
2078 | </li></ol></emu-alg>
|
---|
2079 | </emu-clause>
|
---|
2080 |
|
---|
2081 | <emu-clause id="reflect.deletemetadata">
|
---|
2082 | <h1><span class="secnum">4.1.10</span>Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )</h1>
|
---|
2083 | <p>When the <code>deleteMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
---|
2084 | <emu-alg><ol><li>If <emu-xref aoid="Type" id="_ref_63"><a href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a></emu-xref>(<var>target</var>) is not Object, throw a <emu-val>TypeError</emu-val> exception.</li><li>Return ? <var>target</var>.[[DeleteMetadata]](<var>metadataKey</var>, <var>propertyKey</var>).
|
---|
2085 | </li></ol></emu-alg>
|
---|
2086 | </emu-clause>
|
---|
2087 | </emu-clause>
|
---|
2088 | </emu-clause></div></body> |
---|