@tenjuu99/blog 0.2.34 → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenjuu99/blog",
3
- "version": "0.2.34",
3
+ "version": "0.2.36",
4
4
  "description": "blog template",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -20,10 +20,16 @@ const transition = async (href) => {
20
20
  // load style
21
21
  const styleInline = [...document.styleSheets].filter(s => !s.href)
22
22
  const newStyleInline = [...doc.getElementsByTagName('style')].filter(s => s.dataset.styleName)
23
- newStyleInline.forEach(s => {
24
- const name = s.dataset.styleName
25
- if (!styleInline.find(si => si.ownerNode.dataset.styleName === name)) {
26
- document.head.appendChild(s)
23
+ styleInline.forEach(style => {
24
+ const exist = newStyleInline.find(ns => ns.dataset.styleName === style.ownerNode.dataset.styleName)
25
+ if (!exist) {
26
+ style.ownerNode.remove()
27
+ }
28
+ })
29
+ newStyleInline.forEach(style => {
30
+ const exist = styleInline.find(s => s.ownerNode.dataset.styleName === style.dataset.styleName)
31
+ if (!exist) {
32
+ document.head.appendChild(style)
27
33
  }
28
34
  })
29
35
  window.scroll({top: 0, left: 0, behavior: 'instant'})
@@ -73,9 +79,6 @@ const transition = async (href) => {
73
79
  script.remove()
74
80
  }
75
81
  })
76
- for (let k in window.after_transition) {
77
- window.after_transition[k].apply()
78
- }
79
82
  }
80
83
 
81
84
  const urlFromHref = (href) => {
@@ -102,7 +105,13 @@ const turbolinks = () => {
102
105
  if (`${url.pathname}${url.search}` === `${current.pathname}${current.search}`) {
103
106
  return;
104
107
  }
108
+ for (let k in window.turbolink_before_transition) {
109
+ window.turbolink_before_transition[k].apply()
110
+ }
105
111
  await transition(href)
112
+ for (let k in window.turbolink_after_transition) {
113
+ window.turbolink_after_transition[k].apply()
114
+ }
106
115
  history.pushState({}, '', href)
107
116
  turbolinks()
108
117
  }