WIP: browser and window now cleanly implemented via proxy

This commit is contained in:
Ozbolt Menegatti 2019-11-11 23:01:07 +01:00
parent e62813420e
commit f83faaa6ce
2 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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)