jqh 4 years ago
parent
commit
8f4901ac6e
2 changed files with 11 additions and 2 deletions
  1. 9 0
      resources/views/widgets/markdown.blade.php
  2. 2 2
      src/Traits/HasHtml.php

+ 9 - 0
resources/views/widgets/markdown.blade.php

@@ -1,5 +1,14 @@
 <div {!! $attributes !!}><textarea style="display:none;">{!! $content !!}</textarea></div>
 
+<script first>
+    var ele = window.Element;
+    Dcat.eMatches = ele.prototype.matches ||
+        ele.prototype.msMatchesSelector ||
+        ele.prototype.webkitMatchesSelector;
+</script>
+
 <script require="@editor-md">
     editormd.markdownToHTML('{{ $id }}', {!! admin_javascript_json($options) !!});
+
+    Element.prototype.matches = Dcat.eMatches;
 </script>

+ 2 - 2
src/Traits/HasHtml.php

@@ -129,8 +129,8 @@ trait HasHtml
                 $script = "(function () {{$script}\n})();";
             }
 
-            if ($element->hasAttribute('once')) {
-                return static::script($script);
+            if ($element->hasAttribute('once') || $element->hasAttribute('first')) {
+                return static::script($script, $element->hasAttribute('first'));
             }
 
             return $script;