{"action":"created","issue":{"url":"https://api.github.com/repos/docsifyjs/docsify/issues/907","repository_url":"https://api.github.com/repos/docsifyjs/docsify","labels_url":"https://api.github.com/repos/docsifyjs/docsify/issues/907/labels{/name}","comments_url":"https://api.github.com/repos/docsifyjs/docsify/issues/907/comments","events_url":"https://api.github.com/repos/docsifyjs/docsify/issues/907/events","html_url":"https://github.com/docsifyjs/docsify/issues/907","id":481941803,"node_id":"MDU6SXNzdWU0ODE5NDE4MDM=","number":907,"title":"[bug] `beforeDestroy` lifecycle methods not called on Vue components (memory leak)","user":{"login":"trusktr","id":297678,"node_id":"MDQ6VXNlcjI5NzY3OA==","avatar_url":"https://avatars3.githubusercontent.com/u/297678?v=4","gravatar_id":"","url":"https://api.github.com/users/trusktr","html_url":"https://github.com/trusktr","followers_url":"https://api.github.com/users/trusktr/followers","following_url":"https://api.github.com/users/trusktr/following{/other_user}","gists_url":"https://api.github.com/users/trusktr/gists{/gist_id}","starred_url":"https://api.github.com/users/trusktr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trusktr/subscriptions","organizations_url":"https://api.github.com/users/trusktr/orgs","repos_url":"https://api.github.com/users/trusktr/repos","events_url":"https://api.github.com/users/trusktr/events{/privacy}","received_events_url":"https://api.github.com/users/trusktr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2019-08-18T01:20:12Z","updated_at":"2019-08-18T01:31:02Z","closed_at":null,"author_association":"NONE","body":"<!-- Please don't delete this template or we'll close your issue -->\r\n<!-- Please use English language -->\r\n<!-- Before creating an issue please make sure you are using the latest version of Docsify. -->\r\n<!-- Please ask questions on StackOverflow: https://stackoverflow.com/questions/ask?tags=docsify -->\r\n\r\n## Bug Report\r\n\r\nI noticed that when using Vue in a script tag, the components are not cleaned up when navigating away from the page.\r\n\r\n#### Steps to reproduce\r\n\r\nPut the following in your markdown file:\r\n\r\n```html\r\n<div id=\"example\"></div>\r\n<script type=\"application/javascript\">\r\n  new Vue({\r\n    el: '#example',\r\n    template: `\r\n      <div>blah blah</div>\r\n    `,\r\n    beforeDestroy() {\r\n      debugger . // it never pauses here.\r\n      console.log('DESTROY VUE COMPONENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')\r\n    },\r\n  })\r\n\r\n  console.log('test') // NOTE, this returns undefined.\r\n</script>\r\n```\r\n\r\n\r\n\r\n#### What is current behaviour\r\n\r\nWhen you switch pages, you will not see `DESTROY VUE COMPONENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!` in the console.\r\n\r\n\r\n#### What is the expected behaviour\r\n\r\nWe should see `DESTROY VUE COMPONENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!` in the console.\r\n\r\n`beforeDestroy` is not being fired, which means that components that need to clean up aren't cleaning up, and therefore will cause memory leaks.\r\n\r\n#### Other relevant information\r\n\r\nNote, I disabled `executeScript` from executing my script a second time, due to https://github.com/docsifyjs/docsify/issues/906. I noticed there that it attempts to catch the return value of the script. That's definitely not foolproof.\r\n\r\n<!-- (Update \"[ ]\" to \"[x]\" to check a box) -->\r\n- [x] Bug does still occur when all/other plugins are disabled?\r\n\r\n- Docsify version: 4.9.4\r\n\r\n\r\n<!-- Love docsify? Please consider supporting our collective:\r\n👉  https://opencollective.com/docsify/donate -->\r\n"},"comment":{"url":"https://api.github.com/repos/docsifyjs/docsify/issues/comments/522283049","html_url":"https://github.com/docsifyjs/docsify/issues/907#issuecomment-522283049","issue_url":"https://api.github.com/repos/docsifyjs/docsify/issues/907","id":522283049,"node_id":"MDEyOklzc3VlQ29tbWVudDUyMjI4MzA0OQ==","user":{"login":"trusktr","id":297678,"node_id":"MDQ6VXNlcjI5NzY3OA==","avatar_url":"https://avatars3.githubusercontent.com/u/297678?v=4","gravatar_id":"","url":"https://api.github.com/users/trusktr","html_url":"https://github.com/trusktr","followers_url":"https://api.github.com/users/trusktr/followers","following_url":"https://api.github.com/users/trusktr/following{/other_user}","gists_url":"https://api.github.com/users/trusktr/gists{/gist_id}","starred_url":"https://api.github.com/users/trusktr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trusktr/subscriptions","organizations_url":"https://api.github.com/users/trusktr/orgs","repos_url":"https://api.github.com/users/trusktr/repos","events_url":"https://api.github.com/users/trusktr/events{/privacy}","received_events_url":"https://api.github.com/users/trusktr/received_events","type":"User","site_admin":false},"created_at":"2019-08-18T01:31:02Z","updated_at":"2019-08-18T01:31:02Z","author_association":"NONE","body":"The attempt there, \r\n\r\n```js\r\n    window.__EXECUTE_RESULT__ = new Function(code)()\r\n```\r\n\r\nwon't work anyways. There's no `return` statement, and people aren't going to think to put a top-level `return` statement inside their script tags (let alone the fact that it is being executed twice (#906))."}}
{"actor":{"display_login":"trusktr"}}