![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Lightweight JavaScript DOM manipulation, inspired by jQuery and jqlite, but runs using rollup-compiled, babel transpiled ES6 code.
Lightweight JavaScript DOM manipulation, inspired by jQuery and jqlite, but runs using rollup-compiled, babel transpiled ES6 code.
I wanted an easy wrapper for document.querySelector and querySelector all that mimics the behaviour of jQuery but is still lightweight, manageable and easy to develop.
Include the following snippet in your HTML:
<script src="https://unpkg.com/litequery/dist/litequery.min.js"></script>
Then you can start using it, it'll be attached as the global variable litequery()
.
npm i litequery --save
in your project foldernode_modules/litequery/dist/litequery.min.js
in your project, such as:import litequery from 'litequery';
litequery('div.container').html('Hello World!');
Yes.
import lq from 'litequery';
lq('div').addClass('test').html('asdf');
works just as you would expect.
Some functions do however return variables, such as hasClass('test')
returns a boolean. So those functions break the chain.
import lq from 'litequery';
// Attributes
lq('img#myImg').attr('alt'); // Returns the "alt" text attribute, <img alt="hai"> - result "hai".
lq('img#myImg').attr('alt', 'This is better'); // Sets the "alt" attribute to "This is better".
// Classes
lq('div#myDiv').hasClass('selected'); // Do all the selected elements have the class specified? (returns Boolean)
lq('div#myDiv').dedupClass(); // Deduplicates all classes on all affected elements.
lq('div#myDiv').addClass('highlight'); // Just like jQuery! Add a class to a div.
lq('div#myDiv').removeClass('posh'); // div#myDiv is just not *that* classy after this.
lq('div#myDiv').toggleClass('active'); // Toggle a class
// Content manipulation
lq('#content').html('<h1>Wowza</h1>'); // Set the HTML of #content to "<h1>Wowza</h1>".
var content = lq('#content').html(); // Return #content's innerHTML as a string.
// Events (pretty basic and might not fire accurately at the moment, feel free to contribute)
lq('#hammer').on('touchstart', function(event) {
event.preventDefault(); // Can't touch this
});
// Window events
lq().on('resize', function(event) {
console.log('Awh lag');
});
lq().trigger('resize'); // Trigger resize on window
// Selection
lq('li').single(); // Get the first li item, expects it to be a single element. Warns if multiple selected, but still returns the first.
lq('li').first(); // Get the first matched li item.
lq('li').last(); // Get the last matched li item.
lq('li').parent(); // Get the parent of the first matched item.
lq('ul').children(); // Return the children of all selected objects
lq('li').eq(0); // Get the first matched li item. By index, zero-based.
lq('ul').find('div'); // Traverse the DOM down from UL and select ALL DIVs in each UL.
lq('ul').closest('div'); // Traverse the DOM up from UL and select the first DIV for each UL.
// Advanced selection
lq('li').filter(function(item) {
return item.html(); === 'lol'; // Filter and return all li items containing the world "lol".
});
lq('li').get(); // Returns a NodeList of all matched li elements.
lq('li').get(0); // Returns a specific, non-litequery wrapped element (node) by index, zero-based.
// Apply something to all items using their actual node or element rather than the litequery wrapped one.
lq('.item').apply(function (item) {
item.innerHTML = '';
item.setAttribute('src', '../../test.jpg');
});
// Do something to each and every item, but with a litequery wrapped object.
lq('.item').each(function(item) {
if (item.hasClass('onclear')) {
item.html('');
}
});
// Modify styles
lq('.item').css('background', 'red'); // Turns the background red, same as document.querySelector('.item').style.background = 'red';
lq('.item').css('background'); // Returns 'red'
Yes. Test are in the tests
folder and run by mocha using npm run test
.
If you want to contribute, please do so. Feel free to add pull requests and likewise.
FAQs
Lightweight JavaScript DOM manipulation, inspired by jQuery and jqlite, but runs using rollup-compiled, babel transpiled ES6 code.
The npm package litequery receives a total of 18 weekly downloads. As such, litequery popularity was classified as not popular.
We found that litequery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.