Skip to content

Commit

Permalink
Merge pull request #770 from trheyi/main
Browse files Browse the repository at this point in the history
Securely update add yao.component.GetOptions and deprecated SelectOptions
  • Loading branch information
trheyi authored Nov 3, 2024
2 parents 6263120 + a258dfa commit 8a80704
Show file tree
Hide file tree
Showing 6 changed files with 514 additions and 96 deletions.
29 changes: 28 additions & 1 deletion widgets/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (dsl *DSL) Parse() {
for key, val := range BackendOnlyProps[t] {
if dsl.Props.Has(key) {
for k, v := range val {
dsl.Props[k] = v
dsl.Props[k] = dsl.copy(v)
}
}
}
Expand All @@ -127,3 +127,30 @@ func (dsl *DSL) Clone() *DSL {
}
return &new
}

// Copy the component properties
func (dsl *DSL) copy(v interface{}) interface{} {
var res interface{} = nil
switch v.(type) {
case map[string]interface{}:
// Clone the map
new := map[string]interface{}{}
for k1, v1 := range v.(map[string]interface{}) {
new[k1] = v1
}
res = new

case []interface{}:
// Clone the array
new := []interface{}{}
for _, v1 := range v.([]interface{}) {
new = append(new, dsl.copy(v1))
}
res = new

default:
res = v
}

return res
}
Loading

0 comments on commit 8a80704

Please sign in to comment.