Triply-Dev / YASGUI.YASQE-deprecated

Deprecated, see https://github.com/TriplyDB/Yasgui for the Yasgui monorepo
MIT License
73 stars 36 forks source link

Uncaught TypeError: child.getAllWords is not a function #95

Closed masda70 closed 7 years ago

masda70 commented 7 years ago

When using YASQE in an environment where the Array object has been extended (in my case this is done by Ember.js, which I use), the prefix autocompleter causes the following error to be thrown:

Uncaught TypeError: child.getAllWords is not a function 
  at module.exports.getAllWords (trie.js:235)
  [...]

This happens for instance when writing rdfs: in the editor and expecting YASQE to add the corresponding prefix to the current query. It chokes when hitting the ROOT() of the Trie.

One solution that worked in my case is to perform a safer iteration of T.children properties in the getAllWords function using the standard hasOwnProperty check:

      for(k in T.children) {
        if (T.children.hasOwnProperty(k)){
          child = T.children[k];
          ret = ret.concat(child.getAllWords(str + k));
        }
      }
LaurensRietveld commented 7 years ago

thanks for the report, this should be fixed now in the newest version