notes & logs

This commit is contained in:
metacryst
2024-03-15 16:18:25 -05:00
parent 3b7aad5786
commit 0675c391db
3 changed files with 62 additions and 0 deletions

42
3.14.js Normal file
View File

@@ -0,0 +1,42 @@
/* Class */
// - Force initialization of all variables. Throw error if not enough params passed in
/* State (denoted by "$" in front of the name) */
// - Sync with attributes
// - Proxies to enforce type
// w/ initializers like [] {} 0 ""
// How would one detect class object changes?
// Does object detection go all layers down?
// Swift: Yes, if you change the inner it will rerender the outer.
// struct ContentView: View {
// @State private var outerState = OuterStruct()
// var body: some View {
// Text(outerState.innerState.property)
// .onTapGesture {
// outerState.innerState.property = "New Value"
// }
// }
// }
// struct OuterStruct {
// var innerState = InnerStruct()
// }
// struct InnerStruct {
// var property = "Initial Value"
// }
// Reactivity:
// Parse lines which use the variables?
// Rerender whole thing?
// Lit does only parts which depend, React does whole thing then compares
// Binding
// Objects are passed by reference, str and int by value

View File

@@ -1,5 +1,22 @@
window.testSuites.push( class testParse {
testParseClassFieldsWithNoDefault() {
class Space extends HTMLElement {
form
contents = []
constructor() {
super()
}
}
const fields = window.Registry.parseClassFields(Space);
if(!(JSON.stringify(fields) === JSON.stringify(["form", "contents"]))) {
return `Fields don't match`
}
}
testParseClassFieldsWithEqualityCheck() {
class Space extends HTMLElement {
form = Forms.observe(window.location.pathname, this)

View File

@@ -51,9 +51,12 @@ window.Registry = class Registry {
}
static registerElement = (el, tagname) => {
console.log(this.parseClassFields(el))
let stateVariables = this.parseClassFields(el).filter(field => field.startsWith('$'));
let stateVariablesWithout$ = stateVariables.map(str => str.substring(1));
console.log(stateVariables)
// Observe attributes
Object.defineProperty(el, 'observedAttributes', {
get: function() {