Skip to content

Commit e86d53c

Browse files
committed
only escape for capital globals
1 parent 596a508 commit e86d53c

16 files changed

+101
-887
lines changed

jscomp/bin/all_ounit_tests.ml

-195
Original file line numberDiff line numberDiff line change
@@ -8126,43 +8126,26 @@ let sorted_keywords = [|
81268126
"__esModule";
81278127
"__filename";
81288128
"abstract";
8129-
"alert";
81308129
"arguments";
8131-
"atob";
81328130
"await";
8133-
"blur";
81348131
"boolean";
81358132
"break";
8136-
"btoa";
81378133
"byte";
8138-
"cancelAnimationFrame";
8139-
"cancelIdleCallback";
8140-
"captureEvents";
81418134
"case";
81428135
"catch";
81438136
"char";
81448137
"class";
81458138
"clearImmediate";
81468139
"clearInterval";
81478140
"clearTimeout";
8148-
"clientInformation";
8149-
"close";
8150-
"closed";
8151-
"confirm";
81528141
"console";
81538142
"const";
81548143
"continue";
8155-
"createImageBitmap";
8156-
"crypto";
8157-
"customElements";
81588144
"debugger";
81598145
"decodeURI";
81608146
"decodeURIComponent";
81618147
"default";
8162-
"defaultStatus";
8163-
"defaultstatus";
81648148
"delete";
8165-
"devicePixelRatio";
81668149
"do";
81678150
"document";
81688151
"double";
@@ -8176,239 +8159,61 @@ let sorted_keywords = [|
81768159
"export";
81778160
"exports";
81788161
"extends";
8179-
"external";
81808162
"false";
81818163
"fetch";
81828164
"final";
81838165
"finally";
8184-
"find";
81858166
"float";
8186-
"focus";
81878167
"for";
8188-
"frameElement";
8189-
"frames";
81908168
"function";
8191-
"getComputedStyle";
8192-
"getSelection";
81938169
"global";
8194-
"globalThis";
81958170
"goto";
8196-
"history";
81978171
"if";
81988172
"implements";
81998173
"import";
82008174
"in";
8201-
"indexedDB";
8202-
"innerHeight";
8203-
"innerWidth";
82048175
"instanceof";
82058176
"int";
82068177
"interface";
82078178
"isFinite";
82088179
"isNaN";
8209-
"isSecureContext";
8210-
"length";
82118180
"let";
8212-
"localStorage";
82138181
"location";
8214-
"locationbar";
82158182
"long";
8216-
"matchMedia";
8217-
"menubar";
82188183
"module";
8219-
"moveBy";
8220-
"moveTo";
8221-
"name";
82228184
"native";
82238185
"navigator";
82248186
"new";
82258187
"null";
8226-
"offscreenBuffering";
8227-
"onabort";
8228-
"onafterprint";
8229-
"onanimationend";
8230-
"onanimationiteration";
8231-
"onanimationstart";
8232-
"onappinstalled";
8233-
"onauxclick";
8234-
"onbeforeinstallprompt";
8235-
"onbeforeprint";
8236-
"onbeforeunload";
8237-
"onblur";
8238-
"oncancel";
8239-
"oncanplay";
8240-
"oncanplaythrough";
8241-
"onchange";
8242-
"onclick";
8243-
"onclose";
8244-
"oncontextmenu";
8245-
"oncuechange";
8246-
"ondblclick";
8247-
"ondevicemotion";
8248-
"ondeviceorientation";
8249-
"ondeviceorientationabsolute";
8250-
"ondrag";
8251-
"ondragend";
8252-
"ondragenter";
8253-
"ondragleave";
8254-
"ondragover";
8255-
"ondragstart";
8256-
"ondrop";
8257-
"ondurationchange";
8258-
"onemptied";
8259-
"onended";
8260-
"onerror";
8261-
"onfocus";
8262-
"ongotpointercapture";
8263-
"onhashchange";
8264-
"oninput";
8265-
"oninvalid";
8266-
"onkeydown";
8267-
"onkeypress";
8268-
"onkeyup";
8269-
"onlanguagechange";
8270-
"onload";
8271-
"onloadeddata";
8272-
"onloadedmetadata";
8273-
"onloadstart";
8274-
"onlostpointercapture";
8275-
"onmessage";
8276-
"onmessageerror";
8277-
"onmousedown";
8278-
"onmouseenter";
8279-
"onmouseleave";
8280-
"onmousemove";
8281-
"onmouseout";
8282-
"onmouseover";
8283-
"onmouseup";
8284-
"onmousewheel";
8285-
"onoffline";
8286-
"ononline";
8287-
"onpagehide";
8288-
"onpageshow";
8289-
"onpause";
8290-
"onplay";
8291-
"onplaying";
8292-
"onpointercancel";
8293-
"onpointerdown";
8294-
"onpointerenter";
8295-
"onpointerleave";
8296-
"onpointermove";
8297-
"onpointerout";
8298-
"onpointerover";
8299-
"onpointerup";
8300-
"onpopstate";
8301-
"onprogress";
8302-
"onratechange";
8303-
"onrejectionhandled";
8304-
"onreset";
8305-
"onresize";
8306-
"onscroll";
8307-
"onsearch";
8308-
"onseeked";
8309-
"onseeking";
8310-
"onselect";
8311-
"onselectionchange";
8312-
"onselectstart";
8313-
"onstalled";
8314-
"onstorage";
8315-
"onsubmit";
8316-
"onsuspend";
8317-
"ontimeupdate";
8318-
"ontoggle";
8319-
"ontransitionend";
8320-
"onunhandledrejection";
8321-
"onunload";
8322-
"onvolumechange";
8323-
"onwaiting";
8324-
"onwebkitanimationend";
8325-
"onwebkitanimationiteration";
8326-
"onwebkitanimationstart";
8327-
"onwebkittransitionend";
8328-
"onwheel";
8329-
"open";
8330-
"openDatabase";
8331-
"opener";
8332-
"origin";
8333-
"outerHeight";
8334-
"outerWidth";
83358188
"package";
8336-
"pageXOffset";
8337-
"pageYOffset";
8338-
"parent";
83398189
"parseFloat";
83408190
"parseInt";
8341-
"performance";
8342-
"personalbar";
8343-
"postMessage";
8344-
"print";
83458191
"private";
83468192
"process";
8347-
"prompt";
83488193
"protected";
83498194
"public";
8350-
"queueMicrotask";
8351-
"releaseEvents";
8352-
"requestAnimationFrame";
8353-
"requestIdleCallback";
83548195
"require";
8355-
"resizeBy";
8356-
"resizeTo";
83578196
"return";
8358-
"screen";
8359-
"screenLeft";
8360-
"screenTop";
8361-
"screenX";
8362-
"screenY";
8363-
"scroll";
8364-
"scrollBy";
8365-
"scrollTo";
8366-
"scrollX";
8367-
"scrollY";
8368-
"scrollbars";
8369-
"self";
8370-
"sessionStorage";
83718197
"setImmediate";
83728198
"setInterval";
83738199
"setTimeout";
83748200
"short";
8375-
"speechSynthesis";
83768201
"static";
8377-
"status";
8378-
"statusbar";
8379-
"stop";
8380-
"styleMedia";
83818202
"super";
83828203
"switch";
83838204
"synchronized";
83848205
"then";
83858206
"this";
83868207
"throw";
8387-
"toolbar";
8388-
"top";
83898208
"transient";
83908209
"true";
83918210
"try";
83928211
"typeof";
83938212
"undefined";
83948213
"unescape";
83958214
"var";
8396-
"visualViewport";
83978215
"void";
83988216
"volatile";
8399-
"webkitCancelAnimationFrame";
8400-
"webkitMediaStream";
8401-
"webkitRTCPeerConnection";
8402-
"webkitRequestAnimationFrame";
8403-
"webkitRequestFileSystem";
8404-
"webkitResolveLocalFileSystemURL";
8405-
"webkitSpeechGrammar";
8406-
"webkitSpeechGrammarList";
8407-
"webkitSpeechRecognition";
8408-
"webkitSpeechRecognitionError";
8409-
"webkitSpeechRecognitionEvent";
8410-
"webkitStorageInfo";
8411-
"webkitURL";
84128217
"while";
84138218
"window";
84148219
"with";

jscomp/build_reserved.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ var puppeteer = require('puppeteer');
99
* @type string[]
1010
*/
1111
const result = await page.evaluate(`Object.getOwnPropertyNames(window)`)
12-
fs.writeFileSync('keywords.list',result.join('\n'),'utf8')
12+
fs.writeFileSync('keywords.list',result.filter(x=>/^[A-Z]/.test(x)).join('\n'),'utf8')
1313
await browser.close()
1414
}())

jscomp/build_sorted.ml

+11-6
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"encodeURIComponent";
107107
"escape";
108108
"unescape";
109-
109+
"fetch";
110110
"isNaN";
111111
"parseFloat";
112112
"parseInt";
@@ -209,20 +209,25 @@ let binarySearch (sorted : element array) (key : element) : bool =
209209

210210
let is_reserved s = binarySearch sorted_keywords s
211211
|}
212-
let main () =
213-
let ss = get_predefined_words "keywords.list" in
212+
let main keyword_file output_file =
213+
let ss = get_predefined_words keyword_file in
214214
let ss = fill_extra ss in
215215
let keywords_array =
216216
(SSet.fold
217217
(fun s acc -> acc ^ "\"" ^ s ^ "\";\n "
218218
) ss "let sorted_keywords = [|\n ") ^ "|]\n"
219219
in
220-
let oc = open_out_bin "ext/js_reserved_map.ml" in
220+
let oc = open_out_bin output_file in
221221
output_string oc license ;
222222
output_string oc keywords_array;
223223
output_string oc binary_search;
224224
close_out oc
225-
226-
let () = main ()
225+
(*
226+
;;
227+
for i = 0 to Array.length Sys.argv - 1 do
228+
print_endline ">"; print_string Sys.argv.(i)
229+
done
230+
;; *)
231+
let () = main Sys.argv.(1) "ext/js_reserved_map.ml"
227232

228233

jscomp/compiler.ninja

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ rule gcc
1515
build stubs/ext_basic_hash_stubs.o : gcc stubs/ext_basic_hash_stubs.c
1616
rule ocamlmklib
1717
command = ocamlmklib $in -o $name
18+
19+
rule mk_keywords
20+
command = ocaml $in
21+
generator = true
22+
build ext/js_reserved_map.ml: mk_keywords build_sorted.ml keywords.list
23+
1824
build stubs/libbs_hash.a stubs/dllbs_hash.so: ocamlmklib stubs/ext_basic_hash_stubs.o
1925
name = stubs/bs_hash
2026
rule stubslib

0 commit comments

Comments
 (0)