Skip to content

Commit 234d4ec

Browse files
authoredOct 7, 2023
Merge pull request #60 from WebCoder49/disabled-attribute
Fix HTML attribute synchronisation
2 parents 0242a75 + ed6b156 commit 234d4ec

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed
 

‎code-input.js

+21-26
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,28 @@ var codeInput = {
3131
textareaSyncAttributes: [
3232
"aria-*",
3333
"value",
34-
"name",
3534
// Form validation - https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation#using_built-in_form_validation
36-
"required",
37-
"minlength", "maxlength",
3835
"min", "max",
3936
"type",
40-
"pattern"
37+
"pattern",
38+
39+
// Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
40+
"autocomplete",
41+
"autocorrect",
42+
"autofocus",
43+
"cols",
44+
"dirname",
45+
"disabled",
46+
"form",
47+
"maxlength",
48+
"minlength",
49+
"name",
50+
"placeholder",
51+
"readonly",
52+
"required",
53+
"rows",
54+
"spellcheck",
55+
"wrap"
4156
],
4257

4358
/**
@@ -777,7 +792,8 @@ var codeInput = {
777792
break;
778793
default:
779794
if (codeInput.textareaSyncAttributes.includes(name)) {
780-
if(newValue == null) {
795+
console.log("sync", name, oldValue, newValue);
796+
if(newValue == null || newValue == undefined) { // TODO: Console.Log to check reaches here with disabled attribute; Fix for disabled attr removal
781797
this.textareaElement.removeAttribute(name);
782798
} else {
783799
this.textareaElement.setAttribute(name, newValue);
@@ -939,27 +955,6 @@ var codeInput = {
939955
return this.textareaElement.reportValidity();
940956
}
941957

942-
943-
/**
944-
* @override
945-
*/
946-
setAttribute(qualifiedName, value) {
947-
super.setAttribute(qualifiedName, value); // code-input
948-
if(this.textareaElement != null) {
949-
this.textareaElement.setAttribute(qualifiedName, value); // textarea
950-
}
951-
}
952-
953-
/**
954-
* @override
955-
*/
956-
getAttribute(qualifiedName) {
957-
if (this.textareaElement == null) {
958-
return super.getAttribute(qualifiedName);
959-
}
960-
return this.textareaElement.getAttribute(qualifiedName); // textarea
961-
}
962-
963958
/**
964959
* Allows plugins to store data in the scope of a single element.
965960
* Key - name of the plugin

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Fully customisable, editable syntax-highlighted textareas.",
55
"browser": "code-input.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "echo \"This is a front-end library, not a Node library. Please see the README for how to use.\" && exit 1"
88
},
99
"repository": {
1010
"type": "git",

0 commit comments

Comments
 (0)
Please sign in to comment.