New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cloudfour/elastic-textarea

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudfour/elastic-textarea - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

19

index.js

@@ -9,6 +9,3 @@ customElements.define(

[...this.querySelectorAll("textarea")].forEach((textareaEl) => {
textareaEl.setAttribute(
"data-min-rows",
textareaEl.getAttribute("rows") || 2
);
textareaEl.dataset.minRows = textareaEl.rows || 2;

@@ -19,5 +16,5 @@ // If textareas are prefilled they may need to be resized

// Use event delegation to listent for textarea inputs and update the areas
// Use event delegation to listen for textarea inputs and update the areas
this.addEventListener("input", ({ target }) => {
if (!target instanceof HTMLTextAreaElement) return;
if (!(target instanceof HTMLTextAreaElement)) return;

@@ -43,3 +40,3 @@ this.update(target);

rows++;
textareaEl.setAttribute("rows", String(rows));
textareaEl.rows = rows;

@@ -63,3 +60,3 @@ // Get height after rows change is made

const minRows = parseInt(textareaEl.getAttribute("data-min-rows"));
const minRows = parseInt(textareaEl.dataset.minRows);
let rows = this.rows(textareaEl);

@@ -69,3 +66,3 @@

rows--;
textareaEl.setAttribute("rows", String(Math.max(rows, minRows)));
textareaEl.rows = Math.max(rows, minRows);

@@ -96,7 +93,5 @@ // Get height after rows change is made

rows(textareaEl) {
return parseInt(
textareaEl.getAttribute("rows") || textareaEl.dataset.minRows
);
return textareaEl.rows || parseInt(textareaEl.dataset.minRows);
}
}
);

@@ -1,1 +0,1 @@

customElements.define("elastic-textarea",class extends HTMLElement{connectedCallback(){[...this.querySelectorAll("textarea")].forEach((t=>{t.setAttribute("data-min-rows",t.getAttribute("rows")||2),this.update(t)})),this.addEventListener("input",(({target:t})=>{!t instanceof HTMLTextAreaElement||this.update(t)}))}isScrolling(t){return t.scrollHeight>t.clientHeight}grow(t){let e=t.clientHeight,i=this.rows(t);for(;this.isScrolling(t);){i++,t.setAttribute("rows",String(i));const r=t.clientHeight;if(r===e)break;e=r}}shrink(t){let e=t.clientHeight;const i=parseInt(t.getAttribute("data-min-rows"));let r=this.rows(t);for(;!this.isScrolling(t)&&r>i;){r--,t.setAttribute("rows",String(Math.max(r,i)));if(t.clientHeight===e)break;if(this.isScrolling(t)){this.grow(t);break}}}update(t){this.isScrolling(t)?this.grow(t):this.shrink(t)}rows(t){return parseInt(t.getAttribute("rows")||t.dataset.minRows)}});
customElements.define("elastic-textarea",class extends HTMLElement{connectedCallback(){[...this.querySelectorAll("textarea")].forEach((t=>{t.dataset.minRows=t.rows||2,this.update(t)})),this.addEventListener("input",(({target:t})=>{t instanceof HTMLTextAreaElement&&this.update(t)}))}isScrolling(t){return t.scrollHeight>t.clientHeight}grow(t){let e=t.clientHeight,i=this.rows(t);for(;this.isScrolling(t);){i++,t.rows=i;const s=t.clientHeight;if(s===e)break;e=s}}shrink(t){let e=t.clientHeight;const i=parseInt(t.dataset.minRows);let s=this.rows(t);for(;!this.isScrolling(t)&&s>i;){s--,t.rows=Math.max(s,i);if(t.clientHeight===e)break;if(this.isScrolling(t)){this.grow(t);break}}}update(t){this.isScrolling(t)?this.grow(t):this.shrink(t)}rows(t){return t.rows||parseInt(t.dataset.minRows)}});

@@ -9,3 +9,3 @@ # elastic-textarea

| `isScrolling` | `(textareaEl: any): boolean` | Determine if the element is overflowing |
| `rows` | `(textareaEl: any): number` | |
| `rows` | `(textareaEl: any): any` | |
| `shrink` | `(textareaEl: any): void` | Shrink until the textarea matches the minimum rows or starts overflowing |
{
"name": "@cloudfour/elastic-textarea",
"version": "1.0.6",
"version": "1.0.7",
"description": "A web component for progressively-enhanced auto-expanding textareas",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc