Fix Selection.isCaretOnNewLine to return false if P element is not found

Was throwing error.