Skip to content

Commit

Permalink
Deprecate 'window' API
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Feb 12, 2024
1 parent d172948 commit 15571b7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Barring the script tags needed for PlutoScript's usage, this is the entire sourc
## Pluto API
- `js_invoke(name, ...args)` can be used to invoke a global JavaScript function
- `window.__index.__call`: You can call any method on 'window', e.g. `window.alert("Hello")`
- `document.getElementById(x)` returns an Element instance with path `$"#{x}"`
- `document.querySelector(x)` returns an Element instance with path `x`
- `Element.__index`/`Element.__newindex`: You can read and write any property of an Element, e.g. `.value`
Expand Down
3 changes: 2 additions & 1 deletion plutoscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ dofile = function(src)
return chunk()
end
window = setmetatable({}, { -- silly little thingy to make 'window.alert' work
window = setmetatable({}, {
__index = function(self, key)
return setmetatable({}, {
__call = function(_, ...)
warn("The 'window' API is deprecated. Use 'pluto_invoke' instead.")
js_invoke(key, ...)
end
})
Expand Down

0 comments on commit 15571b7

Please sign in to comment.