@@ -219,11 +219,6 @@ function RemoteFunctions(config) {
219219
220220 } ;
221221
222- // TODO: need to implement
223- function _handleSelectParentOptionClick ( e ) {
224- console . log ( "handle select parent option button was clicked" ) ;
225- }
226-
227222 /**
228223 * This function gets called when the delete button is clicked
229224 * it sends a message to the editor using postMessage to delete the element from the source code
@@ -244,7 +239,7 @@ function RemoteFunctions(config) {
244239 }
245240
246241 /**
247- * For duplicate button. Read '_handleDeleteOptionClick' jsdoc to understand more on how this works
242+ * this is for duplicate button. Read '_handleDeleteOptionClick' jsdoc to understand more on how this works
248243 * @param {Event } event
249244 * @param {DOMElement } element - the HTML DOM element that was clicked. it is to get the data-brackets-id attribute
250245 */
@@ -261,6 +256,32 @@ function RemoteFunctions(config) {
261256 }
262257 }
263258
259+ /**
260+ * this is for select-parent button
261+ * When user clicks on this option for a particular element, we get its parent element and trigger a click on it
262+ * @param {Event } event
263+ * @param {DOMElement } element - the HTML DOM element that was clicked. it is to get the data-brackets-id attribute
264+ */
265+ function _handleSelectParentOptionClick ( event , element ) {
266+ if ( ! element ) {
267+ return ;
268+ }
269+
270+ const parentElement = element . parentElement ;
271+ if ( ! parentElement ) {
272+ return ;
273+ }
274+
275+ // we need to make sure that the parent element is not the body tag or the html.
276+ // also we expect it to have the 'data-brackets-id'
277+ if (
278+ parentElement . tagName !== "BODY" &&
279+ parentElement . tagName !== "HTML" &&
280+ parentElement . hasAttribute ( "data-brackets-id" )
281+ ) {
282+ parentElement . click ( ) ;
283+ }
284+ }
264285
265286 /**
266287 * This function will get triggered when from the multiple advance DOM buttons, one is clicked
0 commit comments