@@ -100,12 +100,70 @@ void DOMDomainCallbackHandlers::ChildNodeRemovedCallback(const v8::FunctionCallb
100
100
}
101
101
102
102
void DOMDomainCallbackHandlers::AttributeModifiedCallback (const v8::FunctionCallbackInfo<v8::Value> &args) {
103
- auto domAgentInstance = V8DOMAgentImpl::Instance;
103
+ try {
104
+ auto domAgentInstance = V8DOMAgentImpl::Instance;
104
105
105
- if (!domAgentInstance) {
106
- return ;
106
+ if (!domAgentInstance) {
107
+ return ;
108
+ }
109
+
110
+ auto isolate = args.GetIsolate ();
111
+
112
+ v8::HandleScope scope (isolate);
113
+
114
+ if (args.Length () != 3 || !(args[0 ]->IsNumber () && args[1 ]->IsString () && args[2 ]->IsString ())) {
115
+ throw NativeScriptException (" Calling AttributeModified with invalid arguments. Required params: nodeId: number, name: string, value: string" );
116
+ }
117
+
118
+ auto nodeId = args[0 ]->ToNumber (isolate);
119
+ auto attributeName = args[1 ]->ToString ();
120
+ auto attributeValue = args[2 ]->ToString ();
121
+
122
+ domAgentInstance->m_frontend .attributeModified (nodeId->Int32Value (),
123
+ ArgConverter::ConvertToString (attributeName).c_str (),
124
+ ArgConverter::ConvertToString (attributeValue).c_str ());
125
+ } catch (NativeScriptException& e) {
126
+ e.ReThrowToV8 ();
127
+ } catch (std::exception e) {
128
+ std::stringstream ss;
129
+ ss << " Error: c exception: " << e.what () << std::endl;
130
+ NativeScriptException nsEx (ss.str ());
131
+ nsEx.ReThrowToV8 ();
132
+ } catch (...) {
133
+ NativeScriptException nsEx (std::string (" Error: c exception!" ));
134
+ nsEx.ReThrowToV8 ();
107
135
}
136
+ }
137
+
138
+ void DOMDomainCallbackHandlers::AttributeRemovedCallback (const v8::FunctionCallbackInfo<v8::Value> &args) {
139
+ try {
140
+ auto domAgentInstance = V8DOMAgentImpl::Instance;
141
+
142
+ if (!domAgentInstance) {
143
+ return ;
144
+ }
145
+ auto isolate = args.GetIsolate ();
146
+
147
+ v8::HandleScope scope (isolate);
148
+
149
+ if (args.Length () != 2 || !(args[0 ]->IsNumber () && args[1 ]->IsString ())) {
150
+ throw NativeScriptException (" Calling AttributeRemoved with invalid arguments. Required params: nodeId: number, name: string" );
151
+ }
108
152
153
+ auto nodeId = args[0 ]->ToNumber (isolate);
154
+ auto attributeName = args[1 ]->ToString ();
109
155
110
- // domAgentInstance->m_frontend.attributeModified();
111
- }
156
+ domAgentInstance->m_frontend .attributeRemoved (nodeId->Int32Value (),
157
+ ArgConverter::ConvertToString (attributeName).c_str ());
158
+ } catch (NativeScriptException& e) {
159
+ e.ReThrowToV8 ();
160
+ } catch (std::exception e) {
161
+ std::stringstream ss;
162
+ ss << " Error: c exception: " << e.what () << std::endl;
163
+ NativeScriptException nsEx (ss.str ());
164
+ nsEx.ReThrowToV8 ();
165
+ } catch (...) {
166
+ NativeScriptException nsEx (std::string (" Error: c exception!" ));
167
+ nsEx.ReThrowToV8 ();
168
+ }
169
+ }
0 commit comments