@@ -152,18 +152,43 @@ namespace v8_inspector {
152
152
*out_object = std::move (resolvedNode);
153
153
}
154
154
155
- void V8DOMAgentImpl::setAttributeValue (ErrorString *, int in_nodeId, const String &in_name,
155
+ void V8DOMAgentImpl::setAttributeValue (ErrorString *errorString , int in_nodeId, const String &in_name,
156
156
const String &in_value) {
157
- // TODO: Pete: call modules' View class methods to set view's attribute
157
+ // Irrelevant
158
158
}
159
159
160
- void V8DOMAgentImpl::setAttributesAsText (ErrorString *, int in_nodeId, const String &in_text,
160
+ void V8DOMAgentImpl::setAttributesAsText (ErrorString *errorString , int in_nodeId, const String &in_text,
161
161
const Maybe<String> &in_name) {
162
- // TODO: Pete: call modules' View class methods to set view's attribute
162
+ // call modules' View class methods to modify view's attribute
163
+ // TODO: Pete: Find a better way to get a hold of the isolate
164
+ std::string setAttributeAsTextFunctionString = " setAttributeAsText" ;
165
+ auto isolate = v8::Isolate::GetCurrent ();
166
+ auto context = isolate->GetCurrentContext ();
167
+ auto global = context->Global ();
168
+
169
+ auto globalInspectorObject = utils::Common::getGlobalInspectorObject (isolate);
170
+
171
+ if (!globalInspectorObject.IsEmpty ()) {
172
+ auto setAttributeAsText = globalInspectorObject->Get (ArgConverter::ConvertToV8String (isolate, setAttributeAsTextFunctionString));
173
+
174
+ if (!setAttributeAsText.IsEmpty () && setAttributeAsText->IsFunction ()) {
175
+ auto setAttributeAsTextFunc = setAttributeAsText.As <v8::Function>();
176
+ v8::Local<v8::Value> args[] = { v8::Number::New (isolate, in_nodeId), ArgConverter::ConvertToV8String (isolate, in_text.utf8 ()), ArgConverter::ConvertToV8String (isolate, in_name.fromJust ().utf8 ()) };
177
+ v8::TryCatch tc;
178
+
179
+ setAttributeAsTextFunc->Call (context, global, 3 , args);
180
+
181
+ if (tc.HasCaught ()) {
182
+ *errorString = utils::Common::getJSCallErrorMessage (setAttributeAsTextFunctionString, tc.Message ()->Get ()).c_str ();
183
+ }
184
+
185
+ return ;
186
+ }
187
+ }
163
188
}
164
189
165
- void V8DOMAgentImpl::removeAttribute (ErrorString *, int in_nodeId, const String &in_name) {
166
- // TODO: Pete: call modules' View class methods to modify view's attribute
190
+ void V8DOMAgentImpl::removeAttribute (ErrorString *errorString , int in_nodeId, const String &in_name) {
191
+ // Irrelevant
167
192
}
168
193
169
194
void V8DOMAgentImpl::performSearch (ErrorString *, const String &in_query,
0 commit comments