WIP: browser and window now cleanly implemented via proxy
This commit is contained in:
parent
e62813420e
commit
f83faaa6ce
|
@ -1,4 +1,5 @@
|
|||
from browser.internal import Document, Window # type: ignore
|
||||
import browser.internal
|
||||
|
||||
document = Document()
|
||||
window = Window()
|
||||
|
||||
document = browser.internal._document
|
||||
window = browser.internal._window
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
# type: ignore
|
||||
|
||||
|
||||
class Document:
|
||||
class Proxy:
|
||||
def __init__(self, proxied):
|
||||
self.proxied = proxied
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return lambda x: document[attr](x)
|
||||
if callable(self.proxied[attr]):
|
||||
return lambda *x: self.proxied[attr](*x)
|
||||
else:
|
||||
return self.proxied[attr]
|
||||
|
||||
|
||||
class Window:
|
||||
def __getattr__(self, attr):
|
||||
return lambda x: window[attr](x)
|
||||
|
||||
_document = Proxy(document)
|
||||
_window = Proxy(window)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user