Misc. (#281)
* Logger * etag cache fix * xml refactor * whitespace * NodePathUtils * Http2
This commit is contained in:
1 parent
44ee6681c5
commit
f3aeb58b38
13 files changed
+104
-75
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import "pkg:/source/utils/NodePathUtils.bs"
|
||||
|
||||
' Bind all nodes that registered for auto-binding
|
||||
' Should be called once from a root node
|
||||
' Can be called later to rebind nodes that were added after the first call
|
||||
@@ -35,7 +37,7 @@ function BindNodeFieldsAndProps(_unused as dynamic) as void
|
||||
if node.getField(fieldId) <> invalid
|
||||
continue for
|
||||
end if
|
||||
reference = FindNodeFromPath(node, bindings.fields[fieldId])
|
||||
reference = NodePathUtils.FindNodeFromPath(node, bindings.fields[fieldId])
|
||||
if reference <> invalid
|
||||
node[fieldId] = reference
|
||||
end if
|
||||
@@ -54,7 +56,7 @@ function BindNodeFieldsAndProps(_unused as dynamic) as void
|
||||
if child.getField(childPropId) <> invalid
|
||||
continue for
|
||||
end if
|
||||
reference = FindNodeFromPath(child, childProps[childPropId])
|
||||
reference = NodePathUtils.FindNodeFromPath(child, childProps[childPropId])
|
||||
if reference <> invalid
|
||||
child[childPropId] = reference
|
||||
end if
|
||||
@@ -63,38 +65,6 @@ function BindNodeFieldsAndProps(_unused as dynamic) as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function FindNodeFromPath(root as object, path as string) as object
|
||||
node = root
|
||||
|
||||
if path.StartsWith("/")
|
||||
node = node.getScene()
|
||||
path = path.Mid(1)
|
||||
end if
|
||||
|
||||
pathParts = path.Tokenize("/")
|
||||
|
||||
for i = 0 to pathParts.Count() - 1
|
||||
if node = invalid
|
||||
return invalid
|
||||
end if
|
||||
if pathParts[i] = "."
|
||||
continue for
|
||||
end if
|
||||
if pathParts[i] = ".."
|
||||
node = node.getParent()
|
||||
continue for
|
||||
end if
|
||||
node = node.findNode(pathParts[i])
|
||||
end for
|
||||
|
||||
if root.isSameNode(node)
|
||||
' if a node is referencing itself, it's probably a mistake
|
||||
return invalid
|
||||
end if
|
||||
|
||||
return node
|
||||
end function
|
||||
|
||||
' Create scoped fields (m.fieldName) for all fields in this node
|
||||
' To be called after BindNodeFieldsAndProps
|
||||
function BindScopeFields(_unused as dynamic)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/tests/AutoBindNode1_bindings.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/tests/AutoBindNode1.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/OnNodeReadyNoOp.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/NodePathUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
||||
<children>
|
||||
<AutoBindNode2 id="AutoBindNode2" />
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/tests/AutoBindNode1Container_bindings.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/tests/AutoBindNode1Container.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/OnNodeReadyNoOp.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/NodePathUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
||||
<children>
|
||||
<AutoBindNode1 id="AutoBindNode1" reference2=".." />
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/tests/AutoBindNode2_bindings.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/tests/AutoBindNode2.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/parts/AutoBind/OnNodeReadyNoOp.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/utils/NodePathUtils.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
|
||||
</component>
|
||||
<!--//# sourceMappingURL=./AutoBindNode2.xml.map -->
|
||||
Reference in new issue
Block a user