-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
track and document caveats with inferredObservability targeting
- Loading branch information
1 parent
4a7509b
commit 83ea8f1
Showing
6 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 41 additions & 11 deletions
52
test/cases/jsx-inferred-observability/fixtures/attribute-changed-callback.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
attributeChangedCallback(name, oldValue, newValue) { | ||
function getValue(value) { | ||
return value.charAt(0) === '{' || value.charAt(0) === '[' ? JSON.parse(value) : !isNaN(value) ? parseInt(value, 10) : value === 'true' || value === 'false' ? value === 'true' ? true : false : value; | ||
} | ||
if (newValue !== oldValue) { | ||
switch (name) { | ||
case 'count': | ||
this.count = getValue(newValue); | ||
break; | ||
} | ||
this.render(); | ||
} | ||
function getValue(value) { | ||
return value.charAt(0) === '{' || value.charAt(0) === '[' ? JSON.parse(value) : !isNaN(value) ? parseInt(value, 10) : value === 'true' || value === 'false' ? value === 'true' ? true : false : value; | ||
} | ||
if (newValue !== oldValue) { | ||
switch (name) { | ||
case 'count': | ||
this.count = getValue(newValue); | ||
break; | ||
} | ||
this.update(name, oldValue, newValue); | ||
} | ||
} | ||
update(name, oldValue, newValue) { | ||
console.debug('Update tracking against....', this.constructor.observedAttributes); | ||
console.debug('Updating', name); | ||
console.debug('Swap old', oldValue); | ||
console.debug('For new', newValue); | ||
console.debug('this[name]', this[name]); | ||
const attr = `data-wcc-${ name }`; | ||
const selector = `[${ attr }]`; | ||
console.debug({ attr }); | ||
console.debug({ selector }); | ||
this.querySelectorAll(selector).forEach(el => { | ||
const needle = oldValue || el.getAttribute(attr); | ||
console.debug({ el }); | ||
console.debug({ needle }); | ||
console.debug({ newValue }); | ||
switch (el.getAttribute('data-wcc-ins')) { | ||
case 'text': | ||
el.textContent = el.textContent.replace(needle, newValue); | ||
break; | ||
case 'attr': | ||
if (el.hasAttribute(el.getAttribute(attr))) { | ||
el.setAttribute(el.getAttribute(attr), newValue); | ||
} | ||
break; | ||
} | ||
}); | ||
if (['count'].includes(name)) { | ||
} | ||
console.debug('****************************'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters