Skip to content

Commit

Permalink
improve and fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Jan 31, 2024
1 parent 3cee17e commit d607ad5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/helpers/attribute-utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { hit } from './hit';
import { logMessage } from './log-message';

/**
* Sets attribute with given value to all elements matching given selector
*
* @param source source object
* @param selector CSS selector
* @param attr attribute name to set
* @param value attribute value to set
*/
export const setAttributeToSelection = (
source: Source,
selector: string,
attr: string,
value: string,
) => {
): void => {
try {
const nodes = document.querySelectorAll(selector);
if (nodes.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/scriptlets/set-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
*
* @description
* Sets attribute with permitted value on the specified elements. This scriptlet runs once when the page loads
* and after that and after that on DOM tree changes.
* and after that on DOM tree changes.
*
* Related UBO scriptlet:
* https://github.com/gorhill/uBlock/wiki/Resources-Library#set-attrjs-
Expand All @@ -28,7 +28,7 @@ import {
*
* - `selector` — required, CSS selector, specifies DOM nodes to set attributes on
* - `attr` — required, attribute to be set
* - `value` — the value to assign to the attribute, defaults to ''. Possible values:
* - `value` — optional, the value to assign to the attribute, defaults to ''. Possible values:
* - `''` — empty string
* - positive decimal integer `<= 32767`
* - `true` / `false` in any case variation
Expand Down
4 changes: 2 additions & 2 deletions src/scriptlets/trusted-set-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
*
* @description
* Sets attribute with arbitrary value on the specified elements. This scriptlet runs once when the page loads
* and after that and after that on DOM tree changes.
* and after that on DOM tree changes.
*
* ### Syntax
*
Expand All @@ -25,7 +25,7 @@ import {
*
* - `selector` — required, CSS selector, specifies DOM nodes to set attributes on
* - `attr` — required, attribute to be set
* - `value` — the value to assign to the attribute, defaults to ''.
* - `value` — optional, the value to assign to the attribute, defaults to ''.
*
* ### Examples
*
Expand Down

0 comments on commit d607ad5

Please sign in to comment.