mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 10:26:12 +02:00
🎉 Add frontend tests for files and events that manage shapes
This commit is contained in:
parent
0cfb66ae16
commit
686814f537
5 changed files with 201 additions and 54 deletions
|
@ -12,6 +12,7 @@
|
|||
[app.common.exceptions :as ex]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.util.object :as obj]
|
||||
[app.util.globals :as globals]
|
||||
[cuerdas.core :as str]
|
||||
[goog.dom :as dom]))
|
||||
|
||||
|
@ -130,9 +131,9 @@
|
|||
|
||||
(defn create-element
|
||||
([tag]
|
||||
(.createElement js/document tag))
|
||||
(.createElement globals/document tag))
|
||||
([ns tag]
|
||||
(.createElementNS js/document ns tag)))
|
||||
(.createElementNS globals/document ns tag)))
|
||||
|
||||
(defn set-html!
|
||||
[el html]
|
||||
|
@ -201,11 +202,11 @@
|
|||
(defn fullscreen?
|
||||
[]
|
||||
(cond
|
||||
(obj/in? js/document "webkitFullscreenElement")
|
||||
(boolean (.-webkitFullscreenElement js/document))
|
||||
(obj/in? globals/document "webkitFullscreenElement")
|
||||
(boolean (.-webkitFullscreenElement globals/document))
|
||||
|
||||
(obj/in? js/document "fullscreenElement")
|
||||
(boolean (.-fullscreenElement js/document))
|
||||
(obj/in? globals/document "fullscreenElement")
|
||||
(boolean (.-fullscreenElement globals/document))
|
||||
|
||||
:else
|
||||
(ex/raise :type :not-supported
|
||||
|
@ -242,17 +243,17 @@
|
|||
(-> event get-target (.releasePointerCapture (.-pointerId event))))
|
||||
|
||||
(defn get-root []
|
||||
(query js/document "#app"))
|
||||
(query globals/document "#app"))
|
||||
|
||||
(defn ^boolean class? [node class-name]
|
||||
(let [class-list (.-classList ^js node)]
|
||||
(.contains ^js class-list class-name)))
|
||||
|
||||
(defn get-user-agent []
|
||||
(.-userAgent js/navigator))
|
||||
(.-userAgent globals/navigator))
|
||||
|
||||
(defn active? [node]
|
||||
(= (.-activeElement js/document) node))
|
||||
(= (.-activeElement globals/document) node))
|
||||
|
||||
(defn get-data [^js node ^string attr]
|
||||
(.getAttribute node (str "data-" attr)))
|
||||
|
|
|
@ -29,6 +29,14 @@ goog.scope(function() {
|
|||
}
|
||||
})();
|
||||
|
||||
app.util.globals.document = (function() {
|
||||
if (typeof goog.global.document !== "undefined") {
|
||||
return goog.global.document;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
app.util.globals.location = (function() {
|
||||
if (typeof goog.global.location !== "undefined") {
|
||||
return goog.global.location;
|
||||
|
@ -36,5 +44,13 @@ goog.scope(function() {
|
|||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
app.util.globals.navigator = (function() {
|
||||
if (typeof goog.global.navigator !== "undefined") {
|
||||
return goog.global.navigator;
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue