回答編集履歴

2

ソースコードを見つけたので追記

2021/10/25 01:57

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア36138

test CHANGED
@@ -13,3 +13,37 @@
13
13
  参考:
14
14
 
15
15
  [Custom elements](https://ja.javascript.info/custom-elements)
16
+
17
+
18
+
19
+ ---
20
+
21
+
22
+
23
+ # ソースコードを見つけたので追記
24
+
25
+
26
+
27
+ [Dawnテーマのデモページ](https://themes.shopify.com/themes/dawn/styles/default/preview?locale=ja)のソースを見てきましたが、やはり独自タグを実装していて、そこで独自メソッドの`setActiveElement`を定義しているようです。
28
+
29
+ このCDNを読み込み忘れている、あるいは読み込み順序を間違えている、などの原因の可能性が高いです。
30
+
31
+
32
+
33
+ ```js
34
+
35
+ class CartNotification extends HTMLElement{constructor(){super(),this.notification=document.getElementById("cart-notification"),this.header=document.querySelector("sticky-header"),this.onBodyClick=this.handleBodyClick.bind(this),this.notification.addEventListener("keyup",(t=>"Escape"===t.code&&this.close())),this.querySelectorAll('button[type="button"]').forEach((t=>t.addEventListener("click",this.close.bind(this))))}
36
+
37
+
38
+
39
+ /...
40
+
41
+
42
+
43
+ setActiveElement(t){this.activeElement=t}}
44
+
45
+ customElements.define("cart-notification",CartNotification);
46
+
47
+ ```
48
+
49
+ [https://cdn.shopify.com/s/files/1/0551/7626/5784/t/31/assets/cart-notification.js?v=1877081553624793631](https://cdn.shopify.com/s/files/1/0551/7626/5784/t/31/assets/cart-notification.js?v=1877081553624793631)

1

参考URLを追記

2021/10/25 01:57

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア36138

test CHANGED
@@ -7,3 +7,9 @@
7
7
 
8
8
 
9
9
  定義が漏れている、依存関係が崩れている、などのことが起きていると思いますので、その部分を確認してみてください。
10
+
11
+
12
+
13
+ 参考:
14
+
15
+ [Custom elements](https://ja.javascript.info/custom-elements)