Ok in fact I think the setDetected method is called just when a pattern is matched so I don't find where it won't works with that.
But you're doing well reading carefully the code because I tested it only on firefox, I think especially for the DOM use.