@srfnstack/fntags 0.3.1 → 0.3.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/fntags.mjs +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srfnstack/fntags",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "author": "Robert Kempton <r@snow87.com>",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/srfnstack/fntags",
package/src/fntags.mjs CHANGED
@@ -78,7 +78,7 @@ export const fntemplate = templateFn => {
78
78
  return ctx => {
79
79
  const clone = rendered.cloneNode(true)
80
80
  for (const selectorClass in placeholders) {
81
- const targetElement = clone.getElementsByClassName(selectorClass)[0]
81
+ const targetElement = clone.classList.contains(selectorClass) ? clone : clone.getElementsByClassName(selectorClass)[0]
82
82
  targetElement.classList.remove(selectorClass)
83
83
  for (const placeholder of placeholders[selectorClass]) {
84
84
  if (!ctx[placeholder.prop]) {
@@ -637,7 +637,7 @@ const setAttribute = function (attrName, attr, element) {
637
637
  }
638
638
  } else if (attrName === 'class') {
639
639
  //special handling for class to ensure the selector classes from fntemplate don't get overwritten
640
- if(element.className) {
640
+ if(element.selector && element.className) {
641
641
  element.className += ` ${attr}`
642
642
  } else {
643
643
  element.className = attr