Hi, I try to make adaptation for React for Brython, but I have faced with the issues ...
During rendering React search all attributes for object and cannot find appropriate props attribute, because this attribute is available on instance window.React.Component.new() ...
Javascript error TypeError: Cannot read property '__name__' of undefined
at Object.type.mro (brython.js:5815)
at Object.$B.$class_constructor (brython.js:5639)
at eval (eval at $B.loop (brython.js:5368), <anonymous>:196:43)
at $B.loop (brython.js:5368)
at $B.inImported (brython.js:5352)
at Object.$B.loop (brython.js:5376)
at $B.run_script (brython.js:5183)
at $B.loop (brython.js:5376)
at XMLHttpRequest.req.onreadystatechange (brython.js:5341)
brython.js:7908 test is js exc is recursion error TypeError: Cannot read property '__name__' of undefined
at Object.type.mro (brython.js:5815)
at Object.$B.$class_constructor (brython.js:5639)
at eval (eval at $B.loop (brython.js:5368), <anonymous>:196:43)
at $B.loop (brython.js:5368)
at $B.inImported (brython.js:5352)
at Object.$B.loop (brython.js:5376)
at $B.run_script (brython.js:5183)
at $B.loop (brython.js:5376)
at XMLHttpRequest.req.onreadystatechange (brython.js:5341) TypeError: Cannot read property '__name__' of undefined
I guess there is missed check if user tries to inherit from JS object by checking if __prototype__ property is available and if this property is available then inheritance should be done something like this:
...
// Builds a basic class object
var A;
if (is_py_class(base)) {
A = {
__class__: _b_.type,
__mro__: [base.__mro__, object],
__name__: name,
$is_class: true
}
} else {
A = {
__class__: _b_.type,
__mro__: [base.prototype, object],
__name__: name,
$is_class: true
}
}
A.$factory = factory
return A
...
I have show example in pseudo code, but anyway idea should be clear, if base object is not class than instead of using its __mro__ in class hierarchy use __prototype__ property
It allows to implement wrappers for JavaScript libraries much easier !! ;)
Hi, I try to make adaptation for React for Brython, but I have faced with the issues ...
During rendering
React
search all attributes for object and cannot find appropriateprops
attribute, because this attribute is available on instancewindow.React.Component.new()
...Test
html
:I try to inherit from
JS
object something like this:I get an error:
In current
Brython
it is line https://github.com/brython-dev/brython/blob/master/www/src/brython.js#L5748Is there a proper way to inherit from
JS
object ?I guess there is missed check if user tries to inherit from
JS
object by checking if__prototype__
property is available and if this property is available then inheritance should be done something like this:I have show example in pseudo code, but anyway idea should be clear, if base object is not class than instead of using its
__mro__
in class hierarchy use__prototype__
propertyIt allows to implement wrappers for
JavaScript
libraries much easier !! ;)