Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return vnode
elif isinstance(vnode, str):
return window.document.createTextNode(vnode)
elif not isinstance(vnode, dict):
raise TypeError('Widget._render_dom() needs virtual nodes '
'to be dicts, not ' + vnode)
if not isinstance(vnode.type, str):
raise TypeError('Widget._render_dom() needs virtual node '
'type to be str, not ' + vnode.type)
if not isinstance(vnode.props, dict):
raise TypeError('Widget._render_dom() needs virtual node '
'props as dict, not ' + vnode.props)
# Resolve the node itself
if node is None or node.nodeName.toLowerCase() != vnode.type.toLowerCase():
node = window.document.createElement(vnode.type)
# Resolve props (i.e. attributes)
map = {'css_class': 'className', 'class': 'className'}
for key, val in vnode.props.items():
ob = node
parts = key.replace('__', '.').split('.')
for i in range(len(parts)-1):
ob = ob[parts[i]]
key = parts[len(parts)-1]
ob[map.get(key, key)] = val
# Resolve content
if vnode.children is None:
pass # dont touch it
elif isinstance(vnode.children, list):
# Truncate children
def _create_dom(self):
return window.document.createElement('span')
def __icon_changed(self, *events):
if self.parent is None and self.container == 'body':
window.document.title = self.title or 'Flexx app'
link = window.document.createElement('link')
oldLink = window.document.getElementById('flexx-favicon')
link.id = 'flexx-favicon'
link.rel = 'shortcut icon'
link.href = events[-1].new_value
if oldLink:
window.document.head.removeChild(oldLink)
window.document.head.appendChild(link)
def _create_dom(self):
return window.document.createElement('div')
def __update_tabs(self):
children = self.children
current = self.current
# Add items to tabbar as needed
while len(self._tabbar.children) < len(children):
node = window.document.createElement('p')
node.classList.add('flx-tab-item')
node.index = len(self._tabbar.children)
self._tabbar.appendChild(node)
# Remove items from tabbar as needed
while len(self._tabbar.children) > len(children):
c = self._tabbar.children[len(self._tabbar.children) - 1]
self._tabbar.removeChild(c)
# Update titles
for i in range(len(children)):
widget = children[i]
node = self._tabbar.children[i]
node.textContent = widget.title
if widget is current:
node.classList.add('flx-current')
def _create_dom(self):
outernode = window.document.createElement('div')
self._tabbar = window.document.createElement('div')
self._tabbar.classList.add('flx-tabbar')
self._addEventListener(self._tabbar, 'mousedown', # also works for touch
self._tabbar_click)
outernode.appendChild(self._tabbar)
return outernode
def _create_dom(self):
outernode = window.document.createElement('div')
self._tabbar = window.document.createElement('div')
self._tabbar.classList.add('flx-tabbar')
self._addEventListener(self._tabbar, 'mousedown', # also works for touch
self._tabbar_click)
outernode.appendChild(self._tabbar)
return outernode