<commit_before>import { create } from 'brisky-struct'
import subscribe from './subscribe'
import findindex from './findindex'
import domElement from './render/dom/element'
import text from './property/text'
import html from './property/html'
import group from './property/group'
import attr from './property/attr'
import css from './property/class'
import style from './property/style'
import widget from './widget'
import events from './events'
import keyevents from './events/key'
import property from './property'

const element = create({
  type: 'element',
  types: {
    property,
    element: 'self'
  },
  instances: false,
  define: {
    isElement: true,
    resolve: false,
    noResolve (val = true) {
      element._c = null
      element._cLevel = null
      element.set({ define: { _noResolve_: val } })
    },
    resolveNodes () {
      // find real inherits
      element._c = null
      element._cLevel = null
      element.set({ define: { resolve: true } })
    },
    removeUnresolved () {
      if (typeof window !== 'undefined') {
        var d = Date.now()
        // has to work better of course
        // will fix this up beter later...
        const elems = this.node.querySelectorAll('[id]')

        // console.log('???', elems)

        // not supported in html element will become different
        var i = elems.length
        var l = 0
        // measure this function
        while (i--) {
          if (elems[i].id > 1e6) {
            l++
            elems[i].parentNode.removeChild(elems[i])
          }
        }
        element._c = null
        element._cLevel = null
        element.set({ define: { resolve: false } })

        // global.ms += Date.now() - d
        console.log(`REMOVE ${l} UN-RESOLVED`, Date.now() - d, 'ms')
      }
    }
  }, // unnesecary code
  props: {
    resolveAttr: (t, val, key, stamp) => {
      var props = t.props
      while (!props) {
        props = t.inherits.props
      }
      const set = {}
      for (let key in val) {
        if (key in props) {
          set[key] = val[key]
        } else {
          if (!set.attr) set.attr = {}
          set.attr[key] = val[key]
        }
      }
      t.set(set, stamp)
    },
    tag: true,
    resolveHash: true,
    default: 'self'
  },
  on: {
    resolve: (val, stamp, element) => {
      if (val) {
        element.resolveNodes()
      } else {
        // element.removeUnresolved()
      }
    }
  },
  tag: 'div',
  inject: [
    subscribe,
    findindex,
    domElement,
    text,
    html,
    group,
    attr,
    css,
    style,
    widget,
    events,
    keyevents
  ]
}, false)

element.set({
  props: {
    // with a subs ? not rly nessecary
    resolve: val => {
      console.log('lets go prerender!')
    }
  }
}, false)

export default element<commit_msg>fixed resolve attr max callstack<commit_after>import { create } from 'brisky-struct'
import subscribe from './subscribe'
import findindex from './findindex'
import domElement from './render/dom/element'
import text from './property/text'
import html from './property/html'
import group from './property/group'
import attr from './property/attr'
import css from './property/class'
import style from './property/style'
import widget from './widget'
import events from './events'
import keyevents from './events/key'
import property from './property'

const element = create({
  type: 'element',
  types: {
    property,
    element: 'self'
  },
  instances: false,
  define: {
    isElement: true,
    resolve: false,
    noResolve (val = true) {
      element._c = null
      element._cLevel = null
      element.set({ define: { _noResolve_: val } })
    },
    resolveNodes () {
      // find real inherits
      element._c = null
      element._cLevel = null
      element.set({ define: { resolve: true } })
    },
    removeUnresolved () {
      if (typeof window !== 'undefined') {
        var d = Date.now()
        // has to work better of course
        // will fix this up beter later...
        const elems = this.node.querySelectorAll('[id]')

        // console.log('???', elems)

        // not supported in html element will become different
        var i = elems.length
        var l = 0
        // measure this function
        while (i--) {
          if (elems[i].id > 1e6) {
            l++
            elems[i].parentNode.removeChild(elems[i])
          }
        }
        element._c = null
        element._cLevel = null
        element.set({ define: { resolve: false } })

        // global.ms += Date.now() - d
        console.log(`REMOVE ${l} UN-RESOLVED`, Date.now() - d, 'ms')
      }
    }
  }, // unnesecary code
  props: {
    resolveAttr: (t, val, key, stamp) => {
      var f = t
      var props
      while (!props && f) {
        props = f.props
        f = f.inherits
      }
      const set = {}
      for (let key in val) {
        if (key in props) {
          set[key] = val[key]
        } else {
          if (!set.attr) set.attr = {}
          set.attr[key] = val[key]
        }
      }
      t.set(set, stamp)
    },
    tag: true,
    resolveHash: true,
    default: 'self'
  },
  on: {
    resolve: (val, stamp, element) => {
      if (val) {
        element.resolveNodes()
      } else {
        // element.removeUnresolved()
      }
    }
  },
  tag: 'div',
  inject: [
    subscribe,
    findindex,
    domElement,
    text,
    html,
    group,
    attr,
    css,
    style,
    widget,
    events,
    keyevents
  ]
}, false)

element.set({
  props: {
    resolve: val => {
      // console.log('lets go prerender!')
    }
  }
}, false)

export default element
{'fraction_non_alphanumeric': 0.1386509635974304, 'fraction_numerical': 0.0010706638115631692, 'mean_word_length': 1.8655419222903886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946995', 'n_tokens_mistral': 1746, 'n_tokens_neox': 1739, 'n_words': 494}