File tree Expand file tree Collapse file tree
docs/components/component Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ The object you use to update the components on the web console. It is also known
2626| ` (Component).type ` | The type of the component, or ** "unknown"** if it isn't known|
2727| ` (Component).parentID ` | The parent ID of the component, if the local thread knows it|
2828| [ ` (Component).parent ` ] ( parent.md ) | Get the parent component of this component|
29- | [ ` (Component).back ` ] ( parent .md) | Syntax sugar: alias for [ ` (Component).parent ` ] ( parent.md ) |
29+ | [ ` (Component).back ` ] ( back .md) | Syntax sugar: alias for [ ` (Component).parent ` ] ( parent.md ) |
3030| ` (Component).isDead ` | Has this component marked removed.|
3131
3232## See Also
Original file line number Diff line number Diff line change 1+ # ` (Component).parent `
2+ A field of [ Component] ( index.md ) that lets you grab the parent component table, if the component knows it's parent.
3+
4+ !!! warning "Type"
5+ This field can be ` nil ` in such cases where the local thread doesn't know the parent of this component, or it is a root component of type ` Tab ` .
6+
7+ ## Alias
8+ ` (Component).back `
9+ : This alias is to make chaining functions more readable.
10+
11+ ## Example
12+ ``` lua
13+ tab :newCard ({ size = 5 , title = " Info" })
14+ :newContainer ()
15+ :addText ({ text = " Hello World" })
16+ :addText ({ text = " I like Mousse!" })
17+ .back
18+ :newCardBody () -- Call on the `Card` component because of the `.back` call above
19+ :addCardTitle ({ text = " Card Title" })
20+ :addCardText ({ text = " Card Text" })
21+ :addCardFooter ({ text = " Card footer" })
22+ ```
23+
24+ ## See Also
25+ - [ Component] ( index.md )
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ plugins:
4444 - search
4545 - mike :
4646 version_selector : true
47+ - redirects :
48+ redirect_maps :
49+ ' components/component/back.md ' : ' components/component/parent.md'
4750
4851extra :
4952 version :
Original file line number Diff line number Diff line change 7878local funcKeys = {
7979 parent = function (raw )
8080 loggingStack .push ()
81+ if not raw .parentID then return nil end
8182 local v = proxy .get (raw .parentID )
8283 loggingStack .pop ()
8384 return v
8485 end ,
8586 back = function (raw ) -- Alias for parent
8687 loggingStack .push ()
88+ if not raw .parentID then return nil end
8789 local v = proxy .get (raw .parentID )
8890 loggingStack .pop ()
8991 return v
@@ -203,6 +205,9 @@ proxy._registerLocalChild = function(parentID, childProxy)
203205end
204206
205207proxy ._unregisterLocalChild = function (parentID , childID )
208+ if not parentID then
209+ return
210+ end
206211 local list = proxy .localChildren [parentID ]
207212 if not list then return end
208213 for i = # list , 1 , - 1 do
You can’t perform that action at this time.
0 commit comments