• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "frameworks/bridge/declarative_frontend/engine/functions/js_xcomponent_onload_function.h"
17 
18 #if defined(XCOMPONENT_SUPPORTED)
19 #include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent_controller.h"
20 #endif
21 #include "frameworks/bridge/declarative_frontend/jsview/js_xcomponent.h"
22 
23 namespace OHOS::Ace::Framework {
24 
ExecuteNew(const std::vector<std::string> & keys,const std::string & param)25 void JsXComponentOnloadFunction::ExecuteNew(const std::vector<std::string>& keys, const std::string& param)
26 {
27     JSRef<JSVal> jsVal;
28     if (keys.size() > 1) {
29         auto result = XComponentClient::GetInstance().GetJSVal(keys[1], jsVal);
30         RefPtr<JSXComponentController> controller =
31             XComponentClient::GetInstance().GetControllerFromJSXComponentControllersMap(keys[1]);
32         if (result && controller) {
33             controller->SetXComponentContext(jsVal);
34         }
35     }
36     ExecuteJS(1, &jsVal);
37 }
38 
39 } // namespace OHOS::Ace::Framework
40