Skip to content

Commit

Permalink
fix: skip super.properties in lit
Browse files Browse the repository at this point in the history
  • Loading branch information
thepassle committed Apr 25, 2024
1 parent 779f6c0 commit bf49c38
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions packages/analyzer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Release 0.9.8
- Skip `...super.properties` in lit's `static properties`

## Release 0.9.7
- Added `scheduleUpdate` to lit's method denylist

Expand Down
8 changes: 5 additions & 3 deletions packages/analyzer/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205310,17 +205310,17 @@ function staticPropertiesPlugin() {
if (isMixin(node)) {
const { mixinFunction, mixinClass } = extractMixinNodes(node);
const { name } = handleName({}, mixinFunction);
handleStaticProperties(mixinClass, moduleDoc, context, name);
handleStaticProperties(mixinClass, moduleDoc, context, name, ts13);
}
break;
case ts13.SyntaxKind.ClassDeclaration:
handleStaticProperties(node, moduleDoc, context);
handleStaticProperties(node, moduleDoc, context, null, ts13);
break;
}
}
};
}
function handleStaticProperties(classNode, moduleDoc, context, mixinName = null) {
function handleStaticProperties(classNode, moduleDoc, context, mixinName = null, ts13) {
let className;
if (!mixinName) {
className = classNode?.name?.getText();
Expand All @@ -205332,6 +205332,8 @@ function handleStaticProperties(classNode, moduleDoc, context, mixinName = null)
if (hasStaticKeyword(member) && member.name.text === "properties") {
const propertiesObject = getPropertiesObject(member);
propertiesObject?.properties?.forEach((property) => {
if (property.kind !== ts13.SyntaxKind.PropertyAssignment)
return;
let classMember = {
kind: "field",
name: property?.name?.getText() || "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { LitElement, property, customElement } from 'lit-element';
class MyElement extends LitElement {
static get properties() {
return {
...super.properties,
prop1: { type: String }, // has default "'foo'"
prop2: { type: Boolean },
attr: { type: String, attribute: 'my-attr' }, // attr output as 'my-attr'
Expand Down
2 changes: 1 addition & 1 deletion packages/analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@custom-elements-manifest/analyzer",
"version": "0.9.7",
"version": "0.9.8",
"description": "",
"license": "MIT",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ export function staticPropertiesPlugin() {
if (isMixin(node)) {
const { mixinFunction, mixinClass } = extractMixinNodes(node);
const { name } = handleName({}, mixinFunction);
handleStaticProperties(mixinClass, moduleDoc, context, name);
handleStaticProperties(mixinClass, moduleDoc, context, name, ts);
}
break;

case ts.SyntaxKind.ClassDeclaration:
handleStaticProperties(node, moduleDoc, context);
handleStaticProperties(node, moduleDoc, context, null, ts);
break;
}
},
};
}

function handleStaticProperties(classNode, moduleDoc, context, mixinName = null) {
function handleStaticProperties(classNode, moduleDoc, context, mixinName = null, ts) {
let className;
if (!mixinName) {
className = classNode?.name?.getText();
Expand All @@ -52,8 +52,9 @@ function handleStaticProperties(classNode, moduleDoc, context, mixinName = null)
classNode?.members?.forEach(member => {
if (hasStaticKeyword(member) && member.name.text === 'properties') {
const propertiesObject = getPropertiesObject(member);

propertiesObject?.properties?.forEach(property => {
if (property.kind !== ts.SyntaxKind.PropertyAssignment) return;

let classMember = {
kind: 'field',
name: property?.name?.getText() || '',
Expand Down

0 comments on commit bf49c38

Please sign in to comment.