diff --git a/spago.yaml b/spago.yaml index ee3ed61..a7ebc15 100644 --- a/spago.yaml +++ b/spago.yaml @@ -23,6 +23,7 @@ package: - node-path - node-process - node-streams + - node-url - nullable - ordered-collections - parallel diff --git a/src/Puppeteer.Handle.HTML.purs b/src/Puppeteer.Handle.HTML.purs index ce5ecdd..2391763 100644 --- a/src/Puppeteer.Handle.HTML.purs +++ b/src/Puppeteer.Handle.HTML.purs @@ -83,14 +83,7 @@ offsetHeight = Eval.unsafeRunJs0 "e => e.offsetHeight" attrs :: forall a. IsElement a => Handle a -> Aff (Map String String) attrs = let - js = String.joinWith "\n" - [ "e => Array.from(e.attributes)" - , " .reduce(" - , " (m, a) => [...m, {k: a.name, v: a.value}]," - , " []," - , " )" - , " .filter(({k}) => k)" - ] + js = "e => Array.from(e.attributes).map(a => ({k: a.name, v: a.value}))" in map FFI.makeMap <<< Eval.unsafeRunJs0 @(Array { k :: String, v :: String }) js diff --git a/src/Puppeteer.Screenshot.purs b/src/Puppeteer.Screenshot.purs index 03d68cb..ba4b08f 100644 --- a/src/Puppeteer.Screenshot.purs +++ b/src/Puppeteer.Screenshot.purs @@ -59,5 +59,5 @@ prepareScreenshotOptions , omitBackground: FFI.maybeToUndefined omitBackground , optimizeForSpeed: FFI.maybeToUndefined optimizeForSpeed , quality: FFI.maybeToUndefined quality - , format: FFI.maybeToUndefined $ map prepareScreenshotFormat format + , type: FFI.maybeToUndefined $ map prepareScreenshotFormat format } diff --git a/test/Puppeteer.Handle.Spec.purs b/test/Puppeteer.Handle.Spec.purs index d383f6f..f8568b9 100644 --- a/test/Puppeteer.Handle.Spec.purs +++ b/test/Puppeteer.Handle.Spec.purs @@ -2,19 +2,23 @@ module Puppeteer.Handle.Spec where import Prelude -import Control.Monad.Error.Class (liftMaybe) +import Control.Monad.Error.Class (liftMaybe, try) import Control.Monad.Rec.Class (Step(..), tailRecM) import Data.Array as Array +import Data.Either (hush) +import Data.Filterable (filterMap) import Data.Map as Map -import Data.Set as Set import Data.Maybe (isJust) import Data.Newtype (wrap) +import Data.Set as Set +import Data.Traversable (for) import Data.Tuple.Nested ((/\)) import Effect (Effect) import Effect.Aff (Aff, forkAff, joinFiber) import Effect.Class (liftEffect) import Effect.Exception (error) import Node.Buffer as Buffer +import Node.URL as Node.URL import Puppeteer as Pup import Puppeteer.Base (timeoutThrow) import Puppeteer.Browser as Pup.Browser @@ -91,6 +95,12 @@ html =
+ + + + + +