spark_web 1.0.0-alpha.3
spark_web: ^1.0.0-alpha.3 copied to clipboard
Server-safe Web API abstraction for Dart. Mirrors the MDN Web API with identical naming so developers can rely on MDN documentation. Works on both the Dart VM (server) and dart2js (browser).
Changelog #
All notable changes to spark_web will be documented in this file.
1.0.0-alpha.3 #
Fixed #
- Fixed
Event.target,Event.currentTarget,FocusEvent.relatedTarget, andTouch.targetreturning genericEventTargetwrappers instead of specificNodewrappers (likeElement). This ensures thatis Nodechecks work correctly on event targets.
1.0.0-alpha.2 #
Changed #
- Updated
Node.containsto acceptEventTarget?instead ofNode?. This fixes issues whereevent.targetcould not be passed directly tocontains.
1.0.0-alpha.1 #
Initial release of the server-safe Web API abstraction.
Added #
Core types (core.dart)
EventTarget—addEventListener,removeEventListener,dispatchEventEvent—type,target,currentTarget,preventDefault,stopPropagationMouseEvent—clientX/Y,pageX/Y,screenX/Y,button, modifier keysKeyboardEvent—key,code,repeat,location, modifier keysInputEvent—data,inputType,isComposingNode— Full tree traversal,appendChild,removeChild,insertBefore,replaceChild,cloneNode,containsNodeList—length,item()MutationObserver—observe,disconnect,takeRecordsMutationRecord—type,target,addedNodes,removedNodes,attributeName,oldValueMutationObserverInit— configuration data class
DOM types (dom.dart)
Element—tagName,id,className,innerHTML,outerHTML,classList,attributes,querySelector,querySelectorAll,getAttribute,setAttribute,removeAttribute,hasAttribute,remove,appendHTMLElement—innerText,hidden,title,style,shadowRoot,attachShadowHTMLDivElement,HTMLSpanElement,HTMLParagraphElementHTMLInputElement—value,type,placeholder,disabled,checked,nameHTMLTextAreaElement—value,placeholder,disabled,rows,colsHTMLButtonElement—disabled,typeHTMLSelectElement—value,selectedIndex,disabledHTMLOptionElement—value,text,selectedHTMLAnchorElement—href,targetHTMLImageElement—src,alt,width,heightHTMLFormElement—action,method,submit(),reset(),reportValidity()HTMLLabelElement—htmlForHTMLTemplateElement—contentDocumentFragment—querySelector,querySelectorAllShadowRoot—host,mode,adoptedStyleSheets,firstElementChildDocument—createElement,createElementNS,createTextNode,createComment,createDocumentFragment,getElementById,querySelector,querySelectorAll,documentElement,body,headText—data,wholeTextComment—data
Collection types (collections.dart)
DOMTokenList—add,remove,toggle,contains,replace,itemNamedNodeMap—item,getNamedItem,removeNamedItemAttr—name,value
CSS types (css.dart)
CSSStyleSheet—replaceSync,replaceCSSStyleDeclaration—getPropertyValue,setProperty,removeProperty,display,visibility,opacity
Window types (window.dart)
Window—document,console,navigator,localStorage,sessionStorage,location,history,crypto,performance,customElements,alert,confirm,prompt,setTimeout,setInterval,requestAnimationFrame,btoa,atobStorage—getItem,setItem,removeItem,clear,key,lengthLocation—href,protocol,host,hostname,port,pathname,search,hash,origin,assign,replace,reloadHistory—pushState,replaceState,back,forward,go,state,lengthNavigator—userAgent,language,languages,onLine,clipboardConsole—log,warn,error,info,debugCrypto—randomUUID()Performance—now()CustomElementRegistry—define,get,upgrade,whenDefinedClipboard—readText,writeText
Global singletons
window— Pre-initializedWindowinstancedocument— Pre-initializedDocumentinstancekIsBrowser—trueon browser,falseon Dart VM
Factory functions
createMutationObserver()— Platform-aware constructorcreateEvent()— Platform-aware constructor
Server implementations
- All types are no-ops or provide Dart-native fallbacks
Storagebacked byMapCrypto.randomUUID()viadart:mathbtoa/atobviadart:convertPerformance.now()viaStopwatchClipboardstores text in memory
Browser implementations
- All types wrap
package:webDOM objects .rawproperty exposes the native JS object