github / query-selector Goto Github PK
View Code? Open in Web Editor NEWQuery the document tree by selector, filtering by element type.
License: MIT License
Query the document tree by selector, filtering by element type.
License: MIT License
I put together a TypeScript type definition for this library now that I'm using it. I could publish it to DefinitelyTyped but it's preferable to keep the definition in the package. Will you accept a PR with this or would you prefer to keep it separate?
The points in the Motivations
section of the README are outdated or not applicable with TypeScript.
Finding an individual element in the document tree and operating on it can lead to null pointer exceptions.
TypeScript now supports optional chaining, and with strictNullChecks
enabled, this should never be an issue.
Even if found, the element may be of the wrong type.
The TypeScript definitions for these methods accept a type parameter, which will assert the return type. Obviously, if the fetched element is actually of a different type, it can still lead to runtime errors. On the plus side, there's no runtime cost for the check. But in my experience, this kind of runtime error is extremely rare. Furthermore, this library will just throw an Error anyway, so it's still going to end up being a runtime error.
This will discourage new users and point them to the vanilla patterns.
This library may still be useful for Flow users.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.