progressively-enhance-web-components 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  - Put your changes here...
6
6
 
7
+ ## 1.0.1
8
+
9
+ - Fixed a bug that prevented camelCase attribute names from replacing `${templateLiteral}` values for values in <template> markup.
10
+ - Updated various dependencies.
11
+
7
12
  ## 1.0.0
8
13
 
9
14
  - Initial commit.
package/README.md CHANGED
@@ -33,7 +33,7 @@ Suppose the intended use of the `<word-count>` component looks like this:
33
33
 
34
34
  And suppose also that you have an Express application with templates loaded into `mvc/views`.
35
35
 
36
- So leverage this module's progressive enhancement technique, you will need to define this component using a `<template>` element in any one of your templates as follows:
36
+ So to leverage this module's progressive enhancement technique, you will need to define this component using a `<template>` element in any one of your templates as follows:
37
37
 
38
38
  ```html
39
39
  <template id="word-count">
@@ -58,7 +58,7 @@ So leverage this module's progressive enhancement technique, you will need to de
58
58
  <div>
59
59
  <textarea rows="10" cols="50" name="${id}" id="${id}">${text}</textarea>
60
60
  <slot name="description"></slot>
61
- <span></span>
61
+ <span class="word-count"></span>
62
62
  </div>
63
63
  </template>
64
64
  ```
@@ -115,7 +115,7 @@ Will be replaced with this:
115
115
  <word-count text="Once upon a time... " id="story">
116
116
  <div>
117
117
  <textarea rows="10" cols="50" name="story" id="story">Once upon a time... </textarea>
118
- <span></span>
118
+ <span class="word-count"></span>
119
119
  </div>
120
120
  <p slot="description">Type your story in the box above!</p>
121
121
  </word-count>
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "url": "https://github.com/rooseveltframework/progressively-enhance-web-components/graphs/contributors"
9
9
  }
10
10
  ],
11
- "version": "1.0.0",
11
+ "version": "1.0.1",
12
12
  "homepage": "https://github.com/rooseveltframework/progressively-enhance-web-components",
13
13
  "license": "CC-BY-4.0",
14
14
  "main": "progressively-enhance-web-components.js",
@@ -78,7 +78,7 @@ module.exports = (params) => {
78
78
  // replace template literals with attribute values in the <template> markup
79
79
  const container = document.createElement('div')
80
80
  container.appendChild(template)
81
- for (const attrib of element.attributes) container.innerHTML = container.innerHTML.replaceAll('${' + attrib.name + '}', attrib.value)
81
+ for (const attrib of element.attributes) container.innerHTML = container.innerHTML.replace(new RegExp(`\\$\\{${attrib.name}\\}`, 'gi'), attrib.value)
82
82
  const componentBeautifyOptions = { ...beautifyOptions }
83
83
  componentBeautifyOptions.preserve_newlines = false // remove newlines from components in case any style, script, or slot elements have been removed
84
84
  container.innerHTML = beautify(container.innerHTML, componentBeautifyOptions)
@@ -39,9 +39,9 @@
39
39
  }
40
40
  </style>
41
41
  <div>
42
- <textarea rows="10" cols="50" name="${id}" id="${id}">${text}</textarea>
42
+ <textarea rows="10" cols="50" name="${elId}" id="${elId}">${text}</textarea>
43
43
  <slot name="description"></slot>
44
- <span></span>
44
+ <span class="word-count"></span>
45
45
  </div>
46
46
  </template>
47
47
  </noparse>
@@ -7,7 +7,7 @@
7
7
  <dd><input type="text" name="your_name" id="your_name" value=""></dd>
8
8
  <dt><label for="story">Tell me a story:</label></dt>
9
9
  <dd>
10
- <word-count text="Once upon a time... " id="story">
10
+ <word-count text="Once upon a time... " elId="story">
11
11
  <p slot="description">Type your story in the box above!</p>
12
12
  </word-count>
13
13
  </dd>
package/test/test.js CHANGED
@@ -28,10 +28,10 @@ describe('progressively-enhance-web-components tests', function () {
28
28
  it('should progressively enhance the <word-count> invocation in the sample app', async function () {
29
29
  const filePath = path.join(sampleAppDir, 'mvc', '.preprocessed_views', 'pageWithForm.html')
30
30
  const fileContent = fs.readFileSync(filePath, 'utf8')
31
- assert(fileContent.includes(`<word-count text="Once upon a time... " id="story">
31
+ assert(fileContent.includes(`<word-count text="Once upon a time... " elid="story">
32
32
  <div>
33
33
  <textarea rows="10" cols="50" name="story" id="story">Once upon a time... </textarea>
34
- <span></span>
34
+ <span class="word-count"></span>
35
35
  </div>
36
36
  <p slot="description">Type your story in the box above!</p>
37
37
  </word-count>`), 'Expected markup not found')