Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A micro-library that lets you easily show and hide elements based on the values of form controls and user interactions elsewhere on the page.
Abel is great when you want to make things happen in the DOM but don't want to load a view library (like React or Angular) or templating framework (like Handlebars or Knockout).
Let's say you've got a signup form and the user shouldn't be able to submit until they agree to your terms and conditions.
Using the data-abel
attribute, it's easy:
<label>
<input type="checkbox" id="terms_agreement_checkbox">
I agree to the terms and conditions
</label>
<button id="submit_button"
data-abel="
i start as hidden.
when #terms_agreement_checkbox is checked, i will show."
type="submit">
Submit
</button>
The first statement will hide the <input id="submit_button">
button as soon as
the script is run. The second statement adds a listener to <input id="terms_agreement_checkbox">
.
Then whenever the user checks it, the submit button will show.
Note: the submit button does not hide when the user unchecks the checkbox. This is because Abel does exactly what you decree and does not execute any other implied actions. To make the button hide if the user unchecks the checkbox, just add another statement to the decree:
<button id="submit_button"
type="submit"
data-abel="
i start as hidden.
when #terms_agreement_checkbox is checked, i will show.
when #terms_agreement_checkbox is not checked, i will hide."
type="submit">
Submit
</button>
Add the following code to your page (just before </body>
):
<script src="path/to/abel.js"></script>
<script> Abel.go(); </script>
This will load Abel and do everything automatically.
Note that if you have a very slow website, elements that Abel will hide (when it's loaded) might be
visible for a short time until the page actually gets to the Abel.go()
block. If this happens, you
basically just need to make your web pages load faster.
If you need more fine-grained control over the items that Abel controls, you can pass in a reference to a DOM node manually:
// Make Abel available for use
var Abel = require('abel');
// Call Abel on a single element (make sure it has a `[data-abel]` attribute with some statements)
Abel( document.getElementById('some-element') );
Of course, you can still call Abel.go()
at any time to automagically initialise all Abel statements.
Using ordinary strings with specific keywords in the data-abel
attribute of an element, Abel will
invisibly do what you ask and your page will react to the interactions you specify.
The API exists entirely within the HTML markup, and Abel will automatically parse it and follow your instructions. The Abel parser reads the sentences as an instruction called a decree and uses JavaScript to execute each statement.
For a decree to be valid, the following rules apply:
I
as well as i
).
)when
, there must be a comma (,
) and a space
before the i will show
or i will hide
.Show / Hide When Run
"i start as hidden"
"i start as showing"
Checkboxes
"when #some_checkbox is checked, i will show."
"when #some_checkbox is not checked, i will hide."
Other Inputs
"when #some_input's value is 'hello', i will show."
"when #some_input's value is not 'hello', i will hide."
"when #some_input's value is less than 10, i will show."
"when #some_input's value is more than 10, i will hide."
FAQs
The declarative DOM manipulator
The npm package abel-dom receives a total of 0 weekly downloads. As such, abel-dom popularity was classified as not popular.
We found that abel-dom 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.