When the VueJS element is rendered on Chrome addon, it suddenly vanishes

I have been using a developer mode addon successfully in Chrome for quite some time.

Now, I want to add a button to my Vue-powered page. Here's the code snippet:


        let isletCtl = document.createElement('div')
        isletCtl.id = "islet-ctl"
        isletCtl.innerText = 'isletCtl: '

        let isletVue = document.createElement('div')
        isletVue.id = 'islet-vue'
        isletVue.innerText = 'isletVue: {{ response }}'
        isletCtl.appendChild(isletVue)
        document.body.appendChild(isletCtl)

        window.setTimeout(function(){
            new Vue({
                el: "#islet-vue",
                data: function(){
                    return {response: 'hello vue'}
                }
            })
        }, 25000)
    

The 25-second delay was just for troubleshooting purposes. The button appears fine initially, but once the Vue rendering happens with Vue({ ... }), the #islet-vue div disappears from the DOM!

Can anyone provide any insight into why this might be happening?

EDIT: Take a look at this screenshot from the Chrome Inspector. It seems like a comment is added, but the actual div#islet-vue element vanishes. https://i.stack.imgur.com/1Np3q.png

EDIT 2: This is my manifest.json file:

{
        "name": "XXX",
        "version": "0.0.3",
        "manifest_version": 3,
        "description": "Simple secure plugin that converts Jira-like text in Slack.",
        "content_scripts": [
            {
                "js": ["js/vue-2.1.6.min.js","tools.js", "common.js", "app.slack.com.v2.js"],
                "css": ["app.slack.com.css"],
                "matches": ["https://app.slack.com/client/*"]
            },
            {
                "js": ["tools.js","common.js","develop/localhost.43000.js"],
                "css": ["develop/localhost.43000.css"],
                "matches": ["http://localhost:43000/*"]
            }
        ],
        "action": {
            "browser_style": true,
            "default_title": "X Islet CORS popup",
            "default_popup": "popup.html"
        },
        "permissions": [
            "tabs",
            "bookmarks",
            "storage"
        ],
        "host_permissions": [
            "http://localhost:8080/",
            "http://localhost:43000/",
            "http://52.117.30.181/*"
        ]
    }

Answer №1

Seems like the issue arises from Vue not having the necessary permissions to manipulate a string on the page from an addon. To resolve this, consider adding a render function to your Vue instance

new Vue({
    el: "#islet-vue",
    render: function(createElement) {
        return createElement('div', {}, this.message)
    },
    data: function() {
        return {
            response: 'hello vue'
        }
    }
})

The problem could be related to how you import Vue, so utilizing webpack (or browserify) can simplify the process of importing external packages.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Conceal rows in the table until the search (filterBy) is completed

Currently, I am utilizing Vue.js version 1.x and plan to update soon. My requirement is to have a table of rows containing some data. To filter the table rows using filterBy, I am using a Vue.js component. However, I want the table rows to remain hidden un ...

Decoding arrays of JSON data

Receiving "chunked" data (json arrays) on the front-end via "xhr" (onprogress). Handling delayed chunks is easy - just remember response length and offset. The challenge comes when multiple "chunked" responses arrive simultaneously, resulting in an unpars ...

Why can't we use percentages to change the max-height property in JavaScript?

I am currently working on creating a responsive menu featuring a hamburger icon. My goal is to have the menu list slide in and out without using jQuery, but instead relying purely on JavaScript. HTML : <div id="animation"> </div> <button ...

Tips for persisting objects created in PHP while utilizing XMLHttpRequest

Currently, I am working on a web page with the index.php file structured as shown below: include('UserClass.php'); include('html/top.php'); $user = new User(); if (isset($_POST['user'], $_POST['pass'])) { $user-& ...

Using ngFor in Angular 6 to create a table with rowspan functionality

Check out this functional code snippet Desire for the table layout: <table class="table table-bordered "> <thead> <tr id="first"> <th id="table-header"> <font color="white">No.</font> </th> <th id="table-hea ...

Encountering a "Cannot GET" error when utilizing mongoose

Details of my router.js file: const express = require("express") const Note = require("../models/nodeModel") const router = express.Router() router.route("/notes").get((req, res) => { Note.find({ show_day: "2020-9-10" }) .then(foundNotes ...

What causes a 500 error when using PHP eval in conjunction with AJAX?

Working within a system where all PHP code resides in a database for dynamic alterations has presented me with an interesting challenge. While the code displays perfectly on the page, calling the same code via AJAX triggers a frustrating error 500. I' ...

Having trouble converting JSON into a JavaScript object

I am encountering an issue with my HTML box: <span>Select department</span><span> <select id="department" onchange="EnableSlaveSelectBox(this)" data-slaveelaments='{"a": 1, "b": "2& ...

Guide to connecting two separate components from distinct pages in React/MUI

My setup involves two pages: Appbar.js, where I have a top appbar and a Navigation Menu Icon Button that triggers the display of my Drawer (Material UI) in TempDrawer.js. Initially, everything worked fine when all the code was placed in the Appbar.js file ...

Error: JSON parsing failed due to an unexpected token 'S' at position 17

Trying to troubleshoot a syntax error in JSON.parse() within a product warranty registration process. Transitioning from Java to AngularJS for this project, I have an API built in PHP handling the back-end operations and a controller managing communication ...

Generate a custom website using React to display multiple copies of a single item dynamically

As a newcomer to React and web development, I've been pondering the possibility of creating dynamic webpages. Let's say I have a .json file containing information about various soccer leagues, structured like this: "api": { "results": 1376, ...

Convert several XML nodes to display in an HTML format

I am currently facing an issue where I am trying to display all the nodes of a specific tag in XML. Although it does filter the data correctly, only one node is showing up. Is there anyone who can assist me with this problem? Below is the XML content: < ...

What is the best way to integrate external JavaScript libraries into Meteor.js?

When working with Meteor, how can I incorporate a 3rd party JavaScript library like gridster.js (http://gridster.net/)? Typically, I would include the script directly in the HTML page. However, is there a way to require it directly in the JavaScript file, ...

The form submission has been cancelled as the form connection is not active - Utilizing VueJs within laravel 8

I am trying to troubleshoot a response issue using the Google inspect tool. Despite checking Network>>XHR, I can't find any response. However, in the console, I saw the message "Form submission canceled because the form is not connected". The sc ...

What is the best way to check for a matching array value in my menu list and apply a corresponding class tag to it?

I need a way to dynamically add a class to tags that match specific array values. My menu list consists of 150 items, and I want to add a class to the tag whose text matches an element in the array. <ul class="nav main" id="tabs"&g ...

What are the steps to implement $navigateTo() in a NativeScript Vue application?

What could be causing $navigateTo(Page) to not work? Visit this link for more information ...

Transmitting JSON Web Tokens from AngularJS to Node.js

A situation has arisen where an AngularJS app must pass a JWT to the Node.js instance that is serving it. The Node.js instance has a /user route which will provide a JWT to the Angular client. What specific modifications should be implemented in the exist ...

Axios - Show the error message returned from validation as [object Object]

Within my API, I include the following validation logic: $request->validate([ 'firstname' => 'required', 'lastname' => 'required', 'username' => 'required|unique:us ...

The JSON property is not defined

After making an AJAX call to retrieve data, I receive a JSON Object instead of a string. When I log the object, all its properties appear correctly. However, when attempting to log one specific property, it shows up as undefined. Here is a snapshot of my ...

Updates made in MobX store are not displaying in the web browser

Why are the data changes not reflecting in the view after the api call? Here is the code snippet that might help: store.js import axios from 'axios'; import {encrypt, decrypt} from '../utils/pgp.js' import {observable, action, compute ...