Fixed img unwrapping
Nichlas W. Andersen
committed Aug 10, 2018
commit ea6106cc101dc41342f0fd53a6e7a09c448620fc
Showing 1
changed file with
13 additions
and 14 deletions
portfolio/.vuepress/theme/Layout.vue
+13
-14
| @@ | @@ -60,24 +60,23 @@ |
| } | |
| } | |
| }, | |
| - | mounted() { |
| - | // unwrap all images from paragraph tags so we can have |
| - | // different widths inside the content. |
| + | updated() { |
| + | // unwrap all images from paragraph tags so we can have |
| + | // different widths inside the content. |
| - | document.querySelectorAll('img').forEach(image => { |
| - | var wrapper = image.parentNode |
| - | let children = wrapper.children |
| - | let fragment = document.createDocumentFragment() |
| + | document.querySelectorAll('p img').forEach(image => { |
| + | var wrapper = image.parentNode |
| + | let children = wrapper.children |
| + | let fragment = document.createDocumentFragment() |
| - | Array.from(children).forEach(child => { |
| - | fragment.appendChild(child) |
| - | }) |
| - | |
| - | wrapper.parentNode.replaceChild(fragment, wrapper) |
| + | Array.from(children).forEach(child => { |
| + | fragment.appendChild(child) |
| + | }) |
| - | }) |
| + | wrapper.parentNode.replaceChild(fragment, wrapper) |
| - | } |
| + | }) |
| + | }, |
| } | |
| </script> | |