Closed AStoker closed 3 years ago
@apvarun I think this is ready for review
@apvarun, see anything I missed in this PR? Would love to get this first draft in. Next steps can be to create a Typescript version which can compile out to native modules or legacy javascript
@apvarun , let me know if there's something I can do to help this get merged in faster
I think we should also reference this new es
file somehow so that the correct file is picked up by bundler
ES6 Conversion + Features
Resolves #15 Added a new file (
toastify-es.js
) which contains an ES6 compliant version of Toastify.Few improvements and changes to behavior:
positionLeft
was finally removeddocument.body
)Notable changes to code:
(function(){...}).bind(this)
)let
instead ofvar
classList
functionality on elementsrootElement
is now stored on the class so when we remove toasts we know where to look specifically (this enhanced the ability of putting toasts inside elements and allows you to use Toastify inside shadowDom nodes)escapeMarkup
to allow optionally unsafeinnerHTML
style
property to directly style the toast (this further extendsbackgroundColor
functionality, and thereforebackgroundColor
should be deprecated in the future in favor of usingstyle.background
). Note, since previous functionality tookbackgroundColor
and applied it to the elementsbackground
style (which changes all background styles), to prevent breaking changes,backgroundColor
takes precedence overstyle.backgroundColor
.Things that should still happen:
text
into theinnerHTML
of the toast (probably just want to useinnerText
, as there's alreadynode
for when you want to pass in an element)