12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724 |
- <!doctype html>
- <head><meta charset="utf-8">
- <title>Metadata Proposal - ECMAScript</title>
- <link rel="stylesheet" href="ecmarkup.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
- <script src="ecmarkup.js"></script>
- <script>
- if (location.hostname === 'rbuckton.github.io' && location.protocol !== 'https:') {
- location.protocol = 'https:';
- }
- </script>
- <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":"","key":"Metadata Proposal - ECMAScript"},{"type":"clause","id":"syntax","aoid":null,"title":"Syntax","titleHTML":"Syntax","number":"1","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","key":"Syntax"},{"type":"op","aoid":"GetOrCreateMetadataMap","refId":"getorcreatemetadatamap","location":"","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":"","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":"","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":"","key":"Abstract Operations"},{"type":"op","aoid":"OrdinaryHasMetadata","refId":"ordinaryhasmetadata","location":"","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":"","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":"","key":"[[HasMetadata]] ( MetadataKey, P )"},{"type":"op","aoid":"OrdinaryHasOwnMetadata","refId":"ordinaryhasownmetadata","location":"","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":"","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":"","key":"[[HasOwnMetadata]] ( MetadataKey, P )"},{"type":"op","aoid":"OrdinaryGetMetadata","refId":"ordinarygetmetadata","location":"","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":"","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":"","key":"[[GetMetadata]] ( MetadataKey, P )"},{"type":"op","aoid":"OrdinaryGetOwnMetadata","refId":"ordinarygetownmetadata","location":"","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":"","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":"","key":"[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )"},{"type":"op","aoid":"OrdinaryDefineOwnMetadata","refId":"ordinarydefineownmetadata","location":"","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":"","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":"","key":"[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )"},{"type":"op","aoid":"OrdinaryMetadataKeys","refId":"ordinarymetadatakeys","location":"","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":"","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":"","key":"[[MetadataKeys]] ( P )"},{"type":"op","aoid":"OrdinaryOwnMetadataKeys","refId":"ordinaryownmetadatakeys","location":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","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":"","key":"The Reflect Object"},{"type":"clause","id":"reflection","aoid":null,"title":"Reflection","titleHTML":"Reflection","number":"4","namespace":"https://rbuckton.github.io/reflect-metadata","location":"","key":"Reflection"}]</script><script>"use strict";
-
- function Search(menu) {
- this.menu = menu;
- this.$search = document.getElementById('menu-search');
- this.$searchBox = document.getElementById('menu-search-box');
- this.$searchResults = document.getElementById('menu-search-results');
-
- this.loadBiblio();
-
- document.addEventListener('keydown', this.documentKeydown.bind(this));
-
- this.$searchBox.addEventListener('keydown', debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true }));
- this.$searchBox.addEventListener('keyup', debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true }));
- }
-
- Search.prototype.loadBiblio = function () {
- var $biblio = document.getElementById('menu-search-biblio');
- if (!$biblio) {
- this.biblio = {};
- } else {
- this.biblio = JSON.parse($biblio.textContent);
- this.biblio.clauses = this.biblio.filter(function (e) { return e.type === 'clause' });
- this.biblio.clausesById = this.biblio.clauses.reduce(function (map, entry) {
- map[entry.id] = entry;
- return map;
- }, {});
- }
- }
-
- Search.prototype.documentKeydown = function (e) {
- if (e.keyCode === 191) {
- e.preventDefault();
- e.stopPropagation();
- this.triggerSearch();
- }
- }
-
- Search.prototype.searchBoxKeydown = function (e) {
- e.stopPropagation();
- e.preventDefault();
- if (e.keyCode === 191 && e.target.value.length === 0) {
- e.preventDefault();
- } else if (e.keyCode === 13) {
- e.preventDefault();
- this.selectResult();
- }
- }
-
- Search.prototype.searchBoxKeyup = function (e) {
- if (e.keyCode === 13 || e.keyCode === 9) {
- return;
- }
-
- this.search(e.target.value);
- }
-
-
- Search.prototype.triggerSearch = function (e) {
- if (this.menu.isVisible()) {
- this._closeAfterSearch = false;
- } else {
- this._closeAfterSearch = true;
- this.menu.show();
- }
-
- this.$searchBox.focus();
- this.$searchBox.select();
- }
- // bit 12 - Set if the result starts with searchString
- // bits 8-11: 8 - number of chunks multiplied by 2 if cases match, otherwise 1.
- // bits 1-7: 127 - length of the entry
- // General scheme: prefer case sensitive matches with fewer chunks, and otherwise
- // prefer shorter matches.
- function relevance(result, searchString) {
- var relevance = 0;
-
- relevance = Math.max(0, 8 - result.match.chunks) << 7;
-
- if (result.match.caseMatch) {
- relevance *= 2;
- }
-
- if (result.match.prefix) {
- relevance += 2048
- }
-
- relevance += Math.max(0, 255 - result.entry.key.length);
-
- return relevance;
- }
-
- Search.prototype.search = function (searchString) {
- var s = Date.now();
-
- if (searchString === '') {
- this.displayResults([]);
- this.hideSearch();
- return;
- } else {
- this.showSearch();
- }
-
- if (searchString.length === 1) {
- this.displayResults([]);
- return;
- }
-
- var results;
-
- if (/^[\d\.]*$/.test(searchString)) {
- results = this.biblio.clauses.filter(function (clause) {
- return clause.number.substring(0, searchString.length) === searchString;
- }).map(function (clause) {
- return { entry: clause };
- });
- } else {
- results = [];
-
- for (var i = 0; i < this.biblio.length; i++) {
- var entry = this.biblio[i];
-
- var match = fuzzysearch(searchString, entry.key);
- if (match) {
- results.push({ entry: entry, match: match });
- }
- }
-
- results.forEach(function (result) {
- result.relevance = relevance(result, searchString);
- });
-
- results = results.sort(function (a, b) { return b.relevance - a.relevance });
-
- }
-
- if (results.length > 50) {
- results = results.slice(0, 50);
- }
-
- this.displayResults(results);
- }
- Search.prototype.hideSearch = function () {
- this.$search.classList.remove('active');
- }
-
- Search.prototype.showSearch = function () {
- this.$search.classList.add('active');
- }
-
- Search.prototype.selectResult = function () {
- var $first = this.$searchResults.querySelector('li:first-child a');
-
- if ($first) {
- document.location = $first.getAttribute('href');
- }
-
- this.$searchBox.value = '';
- this.$searchBox.blur();
- this.displayResults([]);
- this.hideSearch();
-
- if (this._closeAfterSearch) {
- this.menu.hide();
- }
- }
-
- Search.prototype.displayResults = function (results) {
- if (results.length > 0) {
- this.$searchResults.classList.remove('no-results');
-
- var html = '<ul>';
-
- results.forEach(function (result) {
- var entry = result.entry;
- var id = entry.id;
- var cssClass = '';
- var text = '';
-
- if (entry.type === 'clause') {
- var number = entry.number ? entry.number + ' ' : '';
- text = number + entry.key;
- cssClass = 'clause';
- id = entry.id;
- } else if (entry.type === 'production') {
- text = entry.key;
- cssClass = 'prod';
- id = entry.id;
- } else if (entry.type === 'op') {
- text = entry.key;
- cssClass = 'op';
- id = entry.refId;
- } else if (entry.type === 'term') {
- text = entry.key;
- cssClass = 'term';
- id = entry.id || entry.refId;
- }
-
- if (text) {
- html += '<li class=menu-search-result-' + cssClass + '><a href="#' + id + '">' + text + '</a></li>'
- }
- });
-
- html += '</ul>'
-
- this.$searchResults.innerHTML = html;
- } else {
- this.$searchResults.innerHTML = '';
- this.$searchResults.classList.add('no-results');
- }
- }
-
-
- function Menu() {
- this.$toggle = document.getElementById('menu-toggle');
- this.$menu = document.getElementById('menu');
- this.$toc = document.querySelector('menu-toc > ol');
- this.$pins = document.querySelector('#menu-pins');
- this.$pinList = document.getElementById('menu-pins-list');
- this.$toc = document.querySelector('#menu-toc > ol');
- this.$specContainer = document.getElementById('spec-container');
- this.search = new Search(this);
-
- this._pinnedIds = {};
- this.loadPinEntries();
-
- // toggle menu
- this.$toggle.addEventListener('click', this.toggle.bind(this));
-
- // keydown events for pinned clauses
- document.addEventListener('keydown', this.documentKeydown.bind(this));
-
- // toc expansion
- var tocItems = this.$menu.querySelectorAll('#menu-toc li');
- for (var i = 0; i < tocItems.length; i++) {
- var $item = tocItems[i];
- $item.addEventListener('click', function($item, event) {
- $item.classList.toggle('active');
- event.stopPropagation();
- }.bind(null, $item));
- }
-
- // close toc on toc item selection
- var tocLinks = this.$menu.querySelectorAll('#menu-toc li > a');
- for (var i = 0; i < tocLinks.length; i++) {
- var $link = tocLinks[i];
- $link.addEventListener('click', function(event) {
- this.toggle();
- event.stopPropagation();
- }.bind(this));
- }
-
- // update active clause on scroll
- window.addEventListener('scroll', debounce(this.updateActiveClause.bind(this)));
- this.updateActiveClause();
-
- // prevent menu scrolling from scrolling the body
- this.$toc.addEventListener('wheel', function (e) {
- var target = e.currentTarget;
- var offTop = e.deltaY < 0 && target.scrollTop === 0;
- if (offTop) {
- e.preventDefault();
- }
- var offBottom = e.deltaY > 0
- && target.offsetHeight + target.scrollTop >= target.scrollHeight;
-
- if (offBottom) {
- event.preventDefault();
- }
- })
-
- // handle pinning clauses via the pin link
- document.addEventListener('click', function (e) {
- if (e.target.classList.contains('utils-pin')) {
- var id = e.target.parentNode.parentNode.parentNode.parentNode.id;
- this.togglePinEntry(id);
- }
- }.bind(this))
- }
-
- Menu.prototype.documentKeydown = function (e) {
- e.stopPropagation();
- if (e.keyCode === 80) {
- this.togglePinEntry();
- } else if (e.keyCode > 48 && e.keyCode < 58) {
- this.selectPin(e.keyCode - 49);
- }
- }
-
- Menu.prototype.updateActiveClause = function () {
- this.setActiveClause(findActiveClause(this.$specContainer))
- }
-
- Menu.prototype.setActiveClause = function (clause) {
- this.$activeClause = clause;
- this.revealInToc(this.$activeClause);
- }
-
- Menu.prototype.revealInToc = function (path) {
- var current = this.$toc.querySelectorAll('li.revealed');
- for (var i = 0; i < current.length; i++) {
- current[i].classList.remove('revealed');
- current[i].classList.remove('revealed-leaf');
- }
-
- var current = this.$toc;
- var index = 0;
- while (index < path.length) {
- var children = current.children;
- for (var i = 0; i < children.length; i++) {
- if ('#' + path[index].id === children[i].children[1].getAttribute('href') ) {
- children[i].classList.add('revealed');
- if (index === path.length - 1) {
- children[i].classList.add('revealed-leaf');
- var rect = children[i].getBoundingClientRect();
- this.$toc.getBoundingClientRect().top
- var tocRect = this.$toc.getBoundingClientRect();
- if (rect.top + 10 > tocRect.bottom) {
- this.$toc.scrollTop = this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top);
- } else if (rect.top < tocRect.top) {
- this.$toc.scrollTop = this.$toc.scrollTop - (tocRect.top - rect.top);
- }
- }
- current = children[i].querySelector('ol');
- index++;
- break;
- }
- }
-
- }
- }
-
- function findActiveClause(root, path) {
- var clauses = new ClauseWalker(root);
- var $clause;
- var found = false;
- var path = path || [];
-
- while ($clause = clauses.nextNode()) {
- var rect = $clause.getBoundingClientRect();
- var $header = $clause.children[0];
- var marginTop = parseInt(getComputedStyle($header)["margin-top"]);
-
- if ((rect.top - marginTop) <= 0 && rect.bottom > 0) {
- found = true;
- return findActiveClause($clause, path.concat($clause)) || path;
- }
- }
-
- return path;
- }
-
- function ClauseWalker(root) {
- var previous;
- var treeWalker = document.createTreeWalker(
- root,
- NodeFilter.SHOW_ELEMENT,
- {
- acceptNode: function (node) {
- if (previous === node.parentNode) {
- return NodeFilter.FILTER_REJECT;
- } else {
- previous = node;
- }
- if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-INTRO' || node.nodeName === 'EMU-ANNEX') {
- return NodeFilter.FILTER_ACCEPT;
- } else {
- return NodeFilter.FILTER_SKIP;
- }
- }
- },
- false
- );
-
- return treeWalker;
- }
-
- Menu.prototype.toggle = function () {
- this.$menu.classList.toggle('active');
- }
-
- Menu.prototype.show = function () {
- this.$menu.classList.add('active');
- }
-
- Menu.prototype.hide = function () {
- this.$menu.classList.remove('active');
- }
-
- Menu.prototype.isVisible = function() {
- return this.$menu.classList.contains('active');
- }
-
- Menu.prototype.showPins = function () {
- this.$pins.classList.add('active');
- }
-
- Menu.prototype.hidePins = function () {
- this.$pins.classList.remove('active');
- }
-
- Menu.prototype.addPinEntry = function (id) {
- var entry = this.search.biblio.clausesById[id];
- var prefix;
- if (entry.number) {
- prefix = entry.number + ' ';
- } else {
- prefix = '';
- }
- this.$pinList.innerHTML += '<li><a href="#' + entry.id + '">' + prefix + entry.titleHTML + '</a></li>';
- if (Object.keys(this._pinnedIds).length === 0) {
- this.showPins();
- }
- this._pinnedIds[id] = true;
- this.persistPinEntries();
- }
-
- Menu.prototype.removePinEntry = function (id) {
- var item = this.$pinList.querySelector('a[href="#' + id + '"]').parentNode;
- this.$pinList.removeChild(item);
- delete this._pinnedIds[id];
- if (Object.keys(this._pinnedIds).length === 0) {
- this.hidePins();
- }
-
- this.persistPinEntries();
- }
-
- Menu.prototype.persistPinEntries = function () {
- try {
- if (!window.localStorage) return;
- } catch (e) {
- return;
- }
-
- localStorage.pinEntries = JSON.stringify(Object.keys(this._pinnedIds));
- }
-
- Menu.prototype.loadPinEntries = function () {
- try {
- if (!window.localStorage) return;
- } catch (e) {
- return;
- }
-
- var pinsString = window.localStorage.pinEntries;
- if (!pinsString) return;
- var pins = JSON.parse(pinsString);
- for(var i = 0; i < pins.length; i++) {
- this.addPinEntry(pins[i]);
- }
- }
-
- Menu.prototype.togglePinEntry = function (id) {
- if (!id) {
- id = this.$activeClause[this.$activeClause.length - 1].id;
- }
-
- if (this._pinnedIds[id]) {
- this.removePinEntry(id);
- } else {
- this.addPinEntry(id);
- }
- }
-
- Menu.prototype.selectPin = function (num) {
- document.location = this.$pinList.children[num].children[0].href;
- }
-
- function init() {
- var menu = new Menu();
- }
-
- document.addEventListener('DOMContentLoaded', init);
-
- function debounce(fn, opts) {
- opts = opts || {};
- var timeout;
- return function(e) {
- if (opts.stopPropagation) {
- e.stopPropagation();
- }
- var args = arguments;
- if (timeout) {
- clearTimeout(timeout);
- }
- timeout = setTimeout(function() {
- timeout = null;
- fn.apply(this, args);
- }.bind(this), 150);
- }
- }
-
-
-
-
- var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX'];
- function findLocalReferences ($elem) {
- var name = $elem.innerHTML;
- var references = [];
-
- var parentClause = $elem.parentNode;
- while (parentClause && CLAUSE_NODES.indexOf(parentClause.nodeName) === -1) {
- parentClause = parentClause.parentNode;
- }
-
- if(!parentClause) return;
-
- var vars = parentClause.querySelectorAll('var');
-
- for (var i = 0; i < vars.length; i++) {
- var $var = vars[i];
-
- if ($var.innerHTML === name) {
- references.push($var);
- }
- }
-
- return references;
- }
-
- function toggleFindLocalReferences($elem) {
- var references = findLocalReferences($elem);
- if ($elem.classList.contains('referenced')) {
- references.forEach(function ($reference) {
- $reference.classList.remove('referenced');
- });
- } else {
- references.forEach(function ($reference) {
- $reference.classList.add('referenced');
- });
- }
- }
-
- function installFindLocalReferences () {
- document.addEventListener('click', function (e) {
- if (e.target.nodeName === 'VAR') {
- toggleFindLocalReferences(e.target);
- }
- });
- }
-
- document.addEventListener('DOMContentLoaded', installFindLocalReferences);
-
-
-
-
- // The following license applies to the fuzzysearch function
- // The MIT License (MIT)
- // Copyright © 2015 Nicolas Bevacqua
- // Copyright © 2016 Brian Terlson
- // Permission is hereby granted, free of charge, to any person obtaining a copy of
- // this software and associated documentation files (the "Software"), to deal in
- // the Software without restriction, including without limitation the rights to
- // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- // the Software, and to permit persons to whom the Software is furnished to do so,
- // subject to the following conditions:
-
- // The above copyright notice and this permission notice shall be included in all
- // copies or substantial portions of the Software.
-
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
- // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
- // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- function fuzzysearch (searchString, haystack, caseInsensitive) {
- var tlen = haystack.length;
- var qlen = searchString.length;
- var chunks = 1;
- var finding = false;
- var prefix = true;
-
- if (qlen > tlen) {
- return false;
- }
-
- if (qlen === tlen) {
- if (searchString === haystack) {
- return { caseMatch: true, chunks: 1, prefix: true };
- } else if (searchString.toLowerCase() === haystack.toLowerCase()) {
- return { caseMatch: false, chunks: 1, prefix: true };
- } else {
- return false;
- }
- }
-
- outer: for (var i = 0, j = 0; i < qlen; i++) {
- var nch = searchString[i];
- while (j < tlen) {
- var targetChar = haystack[j++];
- if (targetChar === nch) {
- finding = true;
- continue outer;
- }
- if (finding) {
- chunks++;
- finding = false;
- }
- }
-
- if (caseInsensitive) { return false }
-
- return fuzzysearch(searchString.toLowerCase(), haystack.toLowerCase(), true);
- }
-
- return { caseMatch: !caseInsensitive, chunks: chunks, prefix: j <= qlen };
- }
- var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX'];
- function findLocalReferences ($elem) {
- var name = $elem.innerHTML;
- var references = [];
-
- var parentClause = $elem.parentNode;
- while (parentClause && CLAUSE_NODES.indexOf(parentClause.nodeName) === -1) {
- parentClause = parentClause.parentNode;
- }
-
- if(!parentClause) return;
-
- var vars = parentClause.querySelectorAll('var');
-
- for (var i = 0; i < vars.length; i++) {
- var $var = vars[i];
-
- if ($var.innerHTML === name) {
- references.push($var);
- }
- }
-
- return references;
- }
-
- function toggleFindLocalReferences($elem) {
- var references = findLocalReferences($elem);
- if ($elem.classList.contains('referenced')) {
- references.forEach(function ($reference) {
- $reference.classList.remove('referenced');
- });
- } else {
- references.forEach(function ($reference) {
- $reference.classList.add('referenced');
- });
- }
- }
-
- function installFindLocalReferences () {
- document.addEventListener('click', function (e) {
- if (e.target.nodeName === 'VAR') {
- toggleFindLocalReferences(e.target);
- }
- });
- }
-
- document.addEventListener('DOMContentLoaded', installFindLocalReferences);
- </script><style>body {
- display: flex;
- font-size: 18px;
- line-height: 1.5;
- font-family: Cambria, Palatino Linotype, Palatino, Liberation Serif, serif;
- padding: 0;
- margin: 0;
- color: #111;
- }
-
- #spec-container {
- padding-left: 20px;
- flex-grow: 1;
- flex-basis: 66%;
- box-sizing: border-box;
- overflow: hidden;
- }
-
- body.oldtoc {
- margin: 0 auto;
- }
-
- a {
- text-decoration: none;
- color: #206ca7;
- }
-
- a:visited {
- color: #206ca7;
- }
-
- a:hover {
- text-decoration: underline;
- color: #239dee;
- }
-
-
- code {
- font-weight: bold;
- font-family: Consolas, Monaco, monospace;
- white-space: pre;
- }
-
- pre code {
- font-weight: inherit;
- }
-
- pre code.hljs {
- background-color: #fff;
- margin: 0;
- padding: 0;
- }
-
- ol.toc {
- list-style: none;
- padding-left: 0;
- }
-
- ol.toc ol.toc {
- padding-left: 2ex;
- list-style: none;
- }
-
- var {
- color: #2aa198;
- transition: background-color 0.25s ease;
- cursor: pointer;
- }
-
- var.referenced {
- background-color: #ffff33;
- }
-
- emu-const {
- font-family: sans-serif;
- }
-
- emu-val {
- font-weight: bold;
- }
- emu-alg ol, emu-alg ol ol ol ol {
- list-style-type: decimal;
- }
-
- emu-alg ol ol, emu-alg ol ol ol ol ol {
- list-style-type: lower-alpha;
- }
-
- emu-alg ol ol ol, ol ol ol ol ol ol {
- list-style-type: lower-roman;
- }
-
- emu-eqn {
- display: block;
- margin-left: 4em;
- }
-
- emu-eqn.inline {
- display: inline;
- margin: 0;
- }
-
- emu-eqn div:first-child {
- margin-left: -2em;
- }
-
- emu-note {
- margin: 1em 0;
- color: #666;
- border-left: 5px solid #ccc;
- display: flex;
- flex-direction: row;
- }
-
- emu-note > span.note {
- flex-basis: 100px;
- min-width: 100px;
- flex-grow: 0;
- flex-shrink: 1;
- text-transform: uppercase;
- padding-left: 5px;
- }
-
- emu-note[type=editor] {
- border-left-color: #faa;
- }
-
- emu-note > div.note-contents {
- flex-grow: 1;
- flex-shrink: 1;
- }
-
- emu-note > div.note-contents > p:first-child {
- margin-top: 0;
- }
-
- emu-note > div.note-contents > p:last-child {
- margin-bottom: 0;
- }
-
- emu-example {
- display: block;
- margin: 1em 3em;
- }
-
- emu-example figure figcaption {
- margin-top: 0.5em;
- text-align: left;
- }
-
- emu-production {
- display: block;
- margin-top: 1em;
- margin-bottom: 1em;
- margin-left: 5ex;
- }
-
-
- emu-grammar.inline, emu-production.inline,
- emu-grammar.inline emu-production emu-rhs, emu-production.inline emu-rhs {
- display: inline;
- }
-
- emu-grammar[collapsed] emu-production, emu-production[collapsed] {
- margin: 0;
- }
-
- emu-grammar[collapsed] emu-production emu-rhs, emu-production[collapsed] emu-rhs {
- display: inline;
- padding-left: 1ex;
- }
-
- emu-constraints {
- font-size: .75em;
- margin-right: 1ex;
- }
-
- emu-gann {
- margin-right: 1ex;
- }
-
- emu-gann emu-t:last-child,
- emu-gann emu-nt:last-child {
- margin-right: 0;
- }
-
- emu-geq {
- margin-left: 1ex;
- font-weight: bold;
- }
-
- emu-oneof {
- font-weight: bold;
- margin-left: 1ex;
- }
-
- emu-nt {
- display: inline-block;
- font-style: italic;
- white-space: nowrap;
- text-indent: 0;
- }
-
- emu-nt a, emu-nt a:visited {
- color: #333;
- }
-
- emu-rhs emu-nt {
- margin-right: 1ex;
- }
-
- emu-t {
- display: inline-block;
- font-family: monospace;
- font-weight: bold;
- white-space: nowrap;
- text-indent: 0;
- }
-
- emu-production emu-t {
- margin-right: 1ex;
- }
-
- emu-rhs {
- display: block;
- padding-left: 75px;
- text-indent: -25px;
- }
-
- emu-mods {
- font-size: .85em;
- vertical-align: sub;
- font-style: normal;
- font-weight: normal;
- }
-
- emu-production[collapsed] emu-mods {
- display: none;
- }
-
- emu-params, emu-opt {
- margin-right: 1ex;
- font-family: monospace;
- }
-
- emu-params, emu-constraints {
- color: #2aa198;
- }
-
- emu-opt {
- color: #b58900;
- }
-
- emu-gprose {
- font-size: 0.9em;
- font-family: Helvetica, Arial, sans-serif;
- }
-
- h1.shortname {
- color: #f60;
- font-size: 1.5em;
- margin: 0;
- }
-
- h1.version {
- color: #f60;
- font-size: 1.5em;
- margin: 0;
- }
-
- h1.title {
- margin-top: 0;
- color: #f60;
- }
-
- h1.first {
- margin-top: 0;
- }
-
- h1, h2, h3, h4, h5, h6 {
- position: relative;
- }
-
- h1 .secnum {
- text-decoration: none;
- margin-right: 10px;
- }
-
- h1 span.title {
- order: 2;
- }
-
-
- h1 { font-size: 2.67em; margin-top: 2em; margin-bottom: 1em; line-height: 1em;}
- h2 { font-size: 2em; }
- h3 { font-size: 1.56em; }
- h4 { font-size: 1.25em; }
- h5 { font-size: 1.11em; }
- h6 { font-size: 1em; }
-
- h1:hover span.utils {
- display: block;
- }
-
- span.utils {
- font-size: 18px;
- line-height: 18px;
- display: none;
- position: absolute;
- top: 100%;
- left: 0;
- right: 0;
- font-weight: normal;
- }
-
- span.utils:before {
- content: "⤷";
- display: inline-block;
- padding: 0 5px;
- }
-
- span.utils > * {
- display: inline-block;
- margin-right: 20px;
- }
-
- h1 span.utils span.anchor a,
- h2 span.utils span.anchor a,
- h3 span.utils span.anchor a,
- h4 span.utils span.anchor a,
- h5 span.utils span.anchor a,
- h6 span.utils span.anchor a {
- text-decoration: none;
- font-variant: small-caps;
- }
-
- h1 span.utils span.anchor a:hover,
- h2 span.utils span.anchor a:hover,
- h3 span.utils span.anchor a:hover,
- h4 span.utils span.anchor a:hover,
- h5 span.utils span.anchor a:hover,
- h6 span.utils span.anchor a:hover {
- color: #333;
- }
-
- emu-intro h1, emu-clause h1, emu-annex h1 { font-size: 2em; }
- emu-intro h2, emu-clause h2, emu-annex h2 { font-size: 1.56em; }
- emu-intro h3, emu-clause h3, emu-annex h3 { font-size: 1.25em; }
- emu-intro h4, emu-clause h4, emu-annex h4 { font-size: 1.11em; }
- emu-intro h5, emu-clause h5, emu-annex h5 { font-size: 1em; }
- emu-intro h6, emu-clause h6, emu-annex h6 { font-size: 0.9em; }
- emu-intro emu-intro h1, emu-clause emu-clause h1, emu-annex emu-annex h1 { font-size: 1.56em; }
- emu-intro emu-intro h2, emu-clause emu-clause h2, emu-annex emu-annex h2 { font-size: 1.25em; }
- emu-intro emu-intro h3, emu-clause emu-clause h3, emu-annex emu-annex h3 { font-size: 1.11em; }
- emu-intro emu-intro h4, emu-clause emu-clause h4, emu-annex emu-annex h4 { font-size: 1em; }
- emu-intro emu-intro h5, emu-clause emu-clause h5, emu-annex emu-annex h5 { font-size: 0.9em; }
- 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; }
- 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; }
- emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex h3 { font-size: 1em; }
- 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; }
- 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; }
- 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; }
- 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; }
- 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; }
- 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; }
- 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 }
-
- emu-clause {
- display: block;
- }
-
- /* Figures and tables */
- figure { display: block; margin: 1em 0 3em 0; }
- figure object { display: block; margin: 0 auto; }
- figure table.real-table { margin: 0 auto; }
- figure figcaption {
- display: block;
- color: #555555;
- font-weight: bold;
- text-align: center;
- }
-
- emu-table table {
- margin: 0 auto;
- }
-
- emu-table table, table.real-table {
- border-collapse: collapse;
- }
-
- emu-table td, emu-table th, table.real-table td, table.real-table th {
- border: 1px solid black;
- padding: 0.4em;
- vertical-align: baseline;
- }
- emu-table th, emu-table thead td, table.real-table th {
- background-color: #eeeeee;
- }
-
- /* Note: the left content edges of table.lightweight-table >tbody >tr >td
- and div.display line up. */
- table.lightweight-table {
- border-collapse: collapse;
- margin: 0 0 0 1.5em;
- }
- table.lightweight-table td, table.lightweight-table th {
- border: none;
- padding: 0 0.5em;
- vertical-align: baseline;
- }
-
- /* diff styles */
- ins {
- background-color: #e0f8e0;
- text-decoration: none;
- border-bottom: 1px solid #396;
- }
-
- del {
- background-color: #fee;
- }
-
- ins.block, del.block,
- emu-production > ins, emu-production > del,
- emu-grammar > ins, emu-grammar > del {
- display: block;
- }
-
- /* Menu Styles */
- #menu-toggle {
- font-size: 2em;
-
- position: fixed;
- top: 0;
- left: 0;
- width: 1.5em;
- height: 1.5em;
- z-index: 3;
- visibility: hidden;
- color: #1567a2;
- background-color: #fff;
-
- line-height: 1.5em;
- text-align: center;
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;;
-
- cursor: pointer;
- }
-
- #menu {
- display: flex;
- flex-direction: column;
- width: 33%; height: 100vh;
- max-width: 500px;
- box-sizing: border-box;
- background-color: #ddd;
- overflow: hidden;
- transition: opacity 0.1s linear;
- padding: 0 5px;
- position: fixed;
- left: 0; top: 0;
-
- z-index: 2;
- }
-
- #menu-spacer {
- flex-basis: 33%;
- max-width: 500px;
- flex-grow: 0;
- flex-shrink: 0;
- }
-
- #menu a {
- color: #1567a2;
- }
-
- #menu.active {
- display: flex;
- opacity: 1;
- z-index: 2;
- }
-
- #menu-pins {
- flex-grow: 1;
- display: none;
- }
-
- #menu-pins.active {
- display: block;
- }
-
- #menu-pins-list {
- margin: 0;
- padding: 0;
- counter-reset: pins-counter;
- }
-
- #menu-pins-list > li:before {
- content: counter(pins-counter);
- counter-increment: pins-counter;
- display: inline-block;
- width: 25px;
- text-align: center;
- border: 1px solid #bbb;
- padding: 2px;
- margin: 4px;
- box-sizing: border-box;
- line-height: 1em;
- background-color: #ccc;
- border-radius: 4px;
- }
- #menu-toc > ol {
- padding: 0;
- flex-grow: 1;
- }
-
- #menu-toc > ol li {
- padding: 0;
- }
-
- #menu-toc > ol , #menu-toc > ol ol {
- list-style-type: none;
- margin: 0;
- padding: 0;
- }
-
- #menu-toc > ol ol {
- padding-left: 0.75em;
- }
-
- #menu-toc li {
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- }
-
- #menu-toc .item-toggle {
- display: inline-block;
- transform: rotate(-45deg) translate(-5px, -5px);
- transition: transform 0.1s ease;
- text-align: center;
- width: 20px;
-
- color: #aab;
-
- -webkit-touch-callout: none;
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;;
-
- cursor: pointer;
- }
-
- #menu-toc .item-toggle-none {
- display: inline-block;
- width: 20px;
- }
-
- #menu-toc li.active > .item-toggle {
- transform: rotate(45deg) translate(-5px, -5px);
- }
-
- #menu-toc li > ol {
- display: none;
- }
-
- #menu-toc li.active > ol {
- display: block;
- }
-
- #menu-toc li.revealed > a {
- background-color: #bbb;
- font-weight: bold;
- /*
- background-color: #222;
- color: #c6d8e4;
- */
- }
-
- #menu-toc li.revealed-leaf> a {
- color: #206ca7;
- /*
- background-color: #222;
- color: #c6d8e4;
- */
- }
-
- #menu-toc li.revealed > .item-toggle {
- transform: rotate(45deg) translate(-5px, -5px);
- }
-
- #menu-toc li.revealed > ol {
- display: block;
- }
-
- #menu-toc li > a {
- padding: 2px 5px;
- }
-
- #menu > * {
- margin-bottom: 5px;
- }
-
- .menu-pane-header {
- padding: 0 5px;
- text-transform: uppercase;
- background-color: #aaa;
- color: #335;
- font-weight: bold;
- letter-spacing: 2px;
- flex-grow: 0;
- flex-shrink: 0;
- font-size: 0.8em;
- }
-
- #menu-toc {
- display: flex;
- flex-direction: column;
- width: 100%;
- overflow: hidden;
- flex-grow: 1;
- }
-
- #menu-toc ol.toc {
- overflow-x: hidden;
- overflow-y: auto;
- }
-
- #menu-search {
- position: relative;
- flex-grow: 0;
- flex-shrink: 0;
- width: 100%;
-
- display: flex;
- flex-direction: column;
-
- max-height: 300px;
- }
-
- #menu-trace-list {
- display: none;
- }
-
- #menu-search-box {
- box-sizing: border-box;
- display: block;
- width: 100%;
- margin: 5px 0 0 0;
- font-size: 1em;
- padding: 2px;
- background-color: #bbb;
- border: 1px solid #999;
- }
-
- #menu-search-results {
- overflow-x: hidden;
- overflow-y: auto;
- }
-
- li.menu-search-result-clause:before {
- content: 'clause';
- width: 40px;
- display: inline-block;
- text-align: right;
- padding-right: 1ex;
- color: #666;
- font-size: 75%;
- }
- li.menu-search-result-op:before {
- content: 'op';
- width: 40px;
- display: inline-block;
- text-align: right;
- padding-right: 1ex;
- color: #666;
- font-size: 75%;
- }
-
- li.menu-search-result-prod:before {
- content: 'prod';
- width: 40px;
- display: inline-block;
- text-align: right;
- padding-right: 1ex;
- color: #666;
- font-size: 75%
- }
-
-
- li.menu-search-result-term:before {
- content: 'term';
- width: 40px;
- display: inline-block;
- text-align: right;
- padding-right: 1ex;
- color: #666;
- font-size: 75%
- }
-
- #menu-search-results ul {
- padding: 0 5px;
- margin: 0;
- }
-
- #menu-search-results li {
- white-space: nowrap;
- text-overflow: ellipsis;
- }
-
-
- #menu-trace-list {
- counter-reset: item;
- margin: 0 0 0 20px;
- padding: 0;
- }
- #menu-trace-list li {
- display: block;
- white-space: nowrap;
- }
-
- #menu-trace-list li .secnum:after {
- content: " ";
- }
- #menu-trace-list li:before {
- content: counter(item) " ";
- background-color: #222;
- counter-increment: item;
- color: #999;
- width: 20px;
- height: 20px;
- line-height: 20px;
- display: inline-block;
- text-align: center;
- margin: 2px 4px 2px 0;
- }
-
- @media (max-width: 1000px) {
- body {
- margin: 0;
- display: block;
- }
-
- #menu {
- display: none;
- padding-top: 3em;
- width: 450px;
- }
-
- #menu.active {
- position: fixed;
- height: 100%;
- left: 0;
- top: 0;
- right: 300px;
- }
-
- #menu-toggle {
- visibility: visible;
- }
-
- #spec-container {
- padding: 0 5px;
- }
- }
-
- @media only screen and (max-width: 800px) {
- #menu {
- width: 100%;
- }
-
- h1 .secnum:empty {
- margin: 0; padding: 0;
- }
- }
- </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">Pinned Clauses</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">
-
- <emu-intro id="introduction">
- <h1 class="first">Metadata Proposal - ECMAScript<span class="utils"><span class="anchor"><a href="#introduction">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <p>Proposal to add Metadata to ECMAScript.</p>
- </emu-intro>
-
- <emu-clause id="syntax">
- <h1><span class="secnum">1</span>Syntax<span class="utils"><span class="anchor"><a href="#syntax">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <emu-note><span class="note">Note</span><div class="note-contents">This section is non-normative.</div></emu-note>
- <pre><code class="javascript hljs"><span class="hljs-comment">// define metadata on an object or property</span>
- <span class="hljs-built_in">Reflect</span>.defineMetadata(metadataKey, metadataValue, target);
- <span class="hljs-built_in">Reflect</span>.defineMetadata(metadataKey, metadataValue, target, propertyKey);
-
- <span class="hljs-comment">// check for presence of a metadata key on the prototype chain of an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasMetadata(metadataKey, target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasMetadata(metadataKey, target, propertyKey);
-
- <span class="hljs-comment">// check for presence of an own metadata key of an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasOwnMetadata(metadataKey, target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.hasOwnMetadata(metadataKey, target, propertyKey);
-
- <span class="hljs-comment">// get metadata value of a metadata key on the prototype chain of an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadata(metadataKey, target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadata(metadataKey, target, propertyKey);
-
- <span class="hljs-comment">// get metadata value of an own metadata key of an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadata(metadataKey, target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadata(metadataKey, target, propertyKey);
-
- <span class="hljs-comment">// get all metadata keys on the prototype chain of an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadataKeys(target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getMetadataKeys(target, propertyKey);
-
- <span class="hljs-comment">// get all own metadata keys of an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadataKeys(target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.getOwnMetadataKeys(target, propertyKey);
-
- <span class="hljs-comment">// delete metadata from an object or property</span>
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.deleteMetadata(metadataKey, target);
- <span class="hljs-keyword">let</span> result = <span class="hljs-built_in">Reflect</span>.deleteMetadata(metadataKey, target, propertyKey);
-
- <span class="hljs-comment">// apply metadata via a decorator to a constructor</span>
- @<span class="hljs-built_in">Reflect</span>.metadata(metadataKey, metadataValue)
- <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">C</span> </span>{
- <span class="hljs-comment">// apply metadata via a decorator to a method (property)</span>
- @<span class="hljs-built_in">Reflect</span>.metadata(metadataKey, metadataValue)
- method() {
- }
- }
-
- <span class="hljs-comment">// Design-time type annotations</span>
- <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); }
- <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); }
- <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); }
-
- <span class="hljs-comment">// Decorator application</span>
- @ParamTypes(<span class="hljs-built_in">String</span>, <span class="hljs-built_in">Number</span>)
- <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">C</span> </span>{
- <span class="hljs-keyword">constructor</span>(text, i) {
- }
-
- @Type(<span class="hljs-built_in">String</span>)
- get name() { <span class="hljs-keyword">return</span> <span class="hljs-string">"text"</span>; }
-
- @Type(<span class="hljs-built_in">Function</span>)
- @ParamTypes(<span class="hljs-built_in">Number</span>, <span class="hljs-built_in">Number</span>)
- @ReturnType(<span class="hljs-built_in">Number</span>)
- add(x, y) {
- <span class="hljs-keyword">return</span> x + y;
- }
- }
-
- <span class="hljs-comment">// Metadata introspection</span>
- <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>);
- <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>
- </emu-clause>
-
- <emu-clause id="abstract-operations">
- <h1><span class="secnum">2</span>Abstract Operations<span class="utils"><span class="anchor"><a href="#abstract-operations">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <emu-clause id="operations-on-objects">
- <h1><span class="secnum">2.1</span>Operations on Objects<span class="utils"><span class="anchor"><a href="#operations-on-objects">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <emu-clause id="getorcreatemetadatamap" aoid="GetOrCreateMetadataMap">
- <h1><span class="secnum">2.1.1</span>GetOrCreateMetadataMap ( O, P, Create )<span class="utils"><span class="anchor"><a href="#getorcreatemetadatamap">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><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>.
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-and-exotic-objects-behaviors">
- <h1><span class="secnum">3</span>Ordinary and Exotic Objects Behaviors<span class="utils"><span class="anchor"><a href="#ordinary-and-exotic-objects-behaviors">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots">
- <h1><span class="secnum">3.1</span>Ordinary Object Internal Methods and Internal Slots<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-hasmetadata">
- <h1><span class="secnum">3.1.1</span>[[HasMetadata]] ( MetadataKey, P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-hasmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryHasMetadata"><a href="#ordinaryhasmetadata">OrdinaryHasMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
- </li></ol></emu-alg>
- <emu-clause id="ordinaryhasmetadata" aoid="OrdinaryHasMetadata">
- <h1><span class="secnum">3.1.1.1</span>OrdinaryHasMetadata ( MetadataKey, O, P )<span class="utils"><span class="anchor"><a href="#ordinaryhasmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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>.
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-hasownmetadata">
- <h1><span class="secnum">3.1.2</span>[[HasOwnMetadata]] ( MetadataKey, P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-hasownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryHasOwnMetadata"><a href="#ordinaryhasownmetadata">OrdinaryHasOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
- </li></ol></emu-alg>
- <emu-clause id="ordinaryhasownmetadata" aoid="OrdinaryHasOwnMetadata">
- <h1><span class="secnum">3.1.2.1</span>OrdinaryHasOwnMetadata ( MetadataKey, O, P )<span class="utils"><span class="anchor"><a href="#ordinaryhasownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><a href="https://tc39.github.io/ecma262/#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Invoke"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"has"</code>, <var>MetadataKey</var>)).
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-getmetadata">
- <h1><span class="secnum">3.1.3</span>[[GetMetadata]] ( MetadataKey, P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-getmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryGetMetadata"><a href="#ordinarygetmetadata">OrdinaryGetMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
- </li></ol></emu-alg>
- <emu-clause id="ordinarygetmetadata" aoid="OrdinaryGetMetadata">
- <h1><span class="secnum">3.1.3.1</span>OrdinaryGetMetadata ( MetadataKey, O, P )<span class="utils"><span class="anchor"><a href="#ordinarygetmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><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>.
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-getownmetadata">
- <h1><span class="secnum">3.1.4</span>[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-getownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryGetOwnMetadata"><a href="#ordinarygetownmetadata">OrdinaryGetOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>O</var>, <var>P</var>).
- </li></ol></emu-alg>
- <emu-clause id="ordinarygetownmetadata" aoid="OrdinaryGetOwnMetadata">
- <h1><span class="secnum">3.1.4.1</span>OrdinaryGetOwnMetadata ( MetadataKey, O, P )<span class="utils"><span class="anchor"><a href="#ordinarygetownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"get"</code>, <var>MetadataKey</var>).
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-defineownmetadata">
- <h1><span class="secnum">3.1.5</span>[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-defineownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryDefineOwnMetadata"><a href="#ordinarydefineownmetadata">OrdinaryDefineOwnMetadata</a></emu-xref>(<var>MetadataKey</var>, <var>MetadataValue</var>, <var>O</var>, <var>P</var>)
- </li></ol></emu-alg>
- <emu-clause id="ordinarydefineownmetadata" aoid="OrdinaryDefineOwnMetadata">
- <h1><span class="secnum">3.1.5.1</span>OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )<span class="utils"><span class="anchor"><a href="#ordinarydefineownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>When the abstract operation <emu-xref aoid="OrdinaryDefineOwnProperty"><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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><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>).
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-metadatakeys">
- <h1><span class="secnum">3.1.6</span>[[MetadataKeys]] ( P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-metadatakeys">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>When the [[MetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
- <emu-alg><ol><li>Return ? <emu-xref aoid="OrdinaryMetadataKeys"><a href="#ordinarymetadatakeys">OrdinaryMetadataKeys</a></emu-xref>(<var>O</var>, <var>P</var>).
- </li></ol></emu-alg>
- <emu-clause id="ordinarymetadatakeys" aoid="OrdinaryMetadataKeys">
- <h1><span class="secnum">3.1.6.1</span>OrdinaryMetadataKeys ( O, P )<span class="utils"><span class="anchor"><a href="#ordinarymetadatakeys">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><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"><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"><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"><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"><a href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>k</var>).</li><li>Perform ? <emu-xref aoid="Invoke"><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"><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"><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"><a href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>k</var>).</li><li>Perform ? <emu-xref aoid="Invoke"><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"><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"><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>.
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-ownmetadatakeys">
- <h1><span class="secnum">3.1.7</span>[[OwnMetadataKeys]] ( P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-ownmetadatakeys">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>When the [[OwnMetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
- <emu-alg><ol><li>Return <emu-xref aoid="OrdinaryOwnMetadataKeys"><a href="#ordinaryownmetadatakeys">OrdinaryOwnMetadataKeys</a></emu-xref>(<var>O</var>, <var>P</var>).
- </li></ol></emu-alg>
- <emu-clause id="ordinaryownmetadatakeys" aoid="OrdinaryOwnMetadataKeys">
- <h1><span class="secnum">3.1.7.1</span>OrdinaryOwnMetadataKeys ( O, P )<span class="utils"><span class="anchor"><a href="#ordinaryownmetadatakeys">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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"><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>.
- </li></ol></li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="ordinary-object-internal-methods-and-internal-slots-deletemetadata">
- <h1><span class="secnum">3.1.8</span>[[DeleteMetadata]]( MetadataKey, P )<span class="utils"><span class="anchor"><a href="#ordinary-object-internal-methods-and-internal-slots-deletemetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>Assert: <var>P</var> is <emu-val>undefined</emu-val> or <emu-xref aoid="IsPropertyKey"><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"><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"><a href="https://tc39.github.io/ecma262/#sec-invoke">Invoke</a></emu-xref>(<var>metadataMap</var>, <code>"delete"</code>, <var>MetadataKey</var>).
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
- </emu-clause>
-
- <emu-clause id="reflection">
- <h1><span class="secnum">4</span>Reflection<span class="utils"><span class="anchor"><a href="#reflection">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <emu-clause id="reflect">
- <h1><span class="secnum">4.1</span>The Reflect Object<span class="utils"><span class="anchor"><a href="#reflect">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>This section contains amendments to the Reflect object.</p>
- <emu-clause id="reflect-metadatadecoratorfunctions">
- <h1><span class="secnum">4.1.1</span>Metadata Decorator Functions<span class="utils"><span class="anchor"><a href="#reflect-metadatadecoratorfunctions">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>A metadata decorator function is an anonymous built-in function that has [[MetadataKey]] and [[MetadataValue]] internal slots.</p>
- <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>
- <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"><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"><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>.
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.metadata">
- <h1><span class="secnum">4.1.2</span>Reflect.metadata ( metadataKey, metadataValue )<span class="utils"><span class="anchor"><a href="#reflect.metadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>When the <code>metadata</code> function is called with arguments <var>metadataKey</var> and <var>metadataValue</var>, the following steps are taken:</p>
- <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>.
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.definemetadata">
- <h1><span class="secnum">4.1.3</span>Reflect.defineMetadata ( metadataKey, metadataValue, target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.definemetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.hasmetadata">
- <h1><span class="secnum">4.1.4</span>Reflect.hasMetadata ( metadataKey, target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.hasmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.hasownmetadata">
- <h1><span class="secnum">4.1.5</span>Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.hasownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.getmetadata">
- <h1><span class="secnum">4.1.6</span>Reflect.getMetadata ( metadataKey, target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.getmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.getownmetadata">
- <h1><span class="secnum">4.1.7</span>Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.getownmetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.getmetadatakeys">
- <h1><span class="secnum">4.1.8</span>Reflect.getMetadataKeys ( target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.getmetadatakeys">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>When the <code>getMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.getownmetadatakeys">
- <h1><span class="secnum">4.1.9</span>Reflect.getOwnMetadataKeys ( target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.getownmetadatakeys">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <p>When the <code>getOwnMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
-
- <emu-clause id="reflect.deletemetadata">
- <h1><span class="secnum">4.1.10</span>Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )<span class="utils"><span class="anchor"><a href="#reflect.deletemetadata">link</a></span><span class="anchor"><a href="#" class="utils-pin">pin</a></span></span></h1>
- <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>
- <emu-alg><ol><li>If <emu-xref aoid="Type"><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>).
- </li></ol></emu-alg>
- </emu-clause>
- </emu-clause>
- </emu-clause></div></body>
|