notes & logs
This commit is contained in:
42
3.14.js
Normal file
42
3.14.js
Normal 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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
3
index.js
3
index.js
@@ -51,8 +51,11 @@ 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', {
|
||||
|
||||
Reference in New Issue
Block a user