-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML search: represent indices using JavaScript Map instead of object literals #13097
base: master
Are you sure you want to change the base?
Changes from 14 commits
47f6547
713d6bb
0fff170
64d6e09
9bab17c
9b1edac
52b9de3
bcb02fe
7267990
462c859
443fd21
295d230
3498755
f38ce20
0d9a26c
d4bba1e
d9dee52
d056a8a
15a7dfa
6e670ea
f2848ed
798cb48
af61293
2bcf7a6
381c26f
ac281dc
fae81a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ECMAScript | ||
---------- | ||
|
||
This is a sample JavaScript (aka ``ECMAScript``) project used to generate a search engine index fixture. | ||
|
||
Use the `__proto__` property to access the `prototype <https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object_prototypes>`_ (if any) of an object instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @wlach is right that immutability is orthoganal here. I think 'simply' using
JSON.parse
rather than an object literal would solve the__proto__
case. Would we then need to keep thehasOwnProperty
checks?An alternative would be to use a reviver function that constructs
Map
objects/serialise the index withMap
literals, and use.get()
, but that may also be expensive.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, yep - I can revert 443fd21 to remove the use of
Object.freeze
/ the reviver function.We should keep those, I think. Without them, queries for
__proto__
may continue to inadvertently retrieve object prototypes instead of getting anundefined
result.What do you think about constructing those
Map
objects directly in thesearchindex.js
file format, instead of usingJSON.parse
and a reviver?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is definitely worth a shot, I suspect it'll be quite fast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm giving it a try - it doesn't seem too tricky; the Python serialization of the search index becomes a little more complex. One challenge that I have yet to work out is how the Python unit tests should parse/load the resulting index (ref:
sphinx/tests/test_search.py
Line 70 in 15b46dc