Skip to content

Commit

Permalink
Remove warnings (#450)
Browse files Browse the repository at this point in the history
Had some fundamental issues we need to resolve before we can bring it back.
  • Loading branch information
dhh authored Sep 23, 2021
1 parent ea83097 commit 477e118
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 188 deletions.
9 changes: 0 additions & 9 deletions src/core/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class Application implements ErrorHandler {
readonly router: Router
logger: Logger = console
debug: boolean = false
warnings: boolean = true

static start(element?: Element, schema?: Schema): Application {
const application = new Application(element, schema)
Expand Down Expand Up @@ -74,14 +73,6 @@ export class Application implements ErrorHandler {
return context ? context.controller : null
}

// Warning handling

handleWarning(warning: string, message: string, detail: object) {
if (this.warnings) {
this.logger.warn(`%s\n\n%s\n\n%o`, message, warning, detail)
}
}

// Error handling

handleError(error: Error, message: string, detail: object) {
Expand Down
18 changes: 0 additions & 18 deletions src/core/binding_observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,8 @@ export class BindingObserver implements ValueListObserverDelegate<Action> {

private connectAction(action: Action) {
const binding = new Binding(this.context, action)
const { controller } = binding.context
const method = (controller as any)[action.methodName]

this.bindingsByAction.set(action, binding)
this.delegate.bindingConnected(binding)

if (typeof method != "function") {
this.context.handleWarning(
`Action "${action.toString()}" references undefined method "${action.methodName}" on controller "${action.identifier}"`,
`connecting action "${action.toString()}"`
)
}
}

private disconnectAction(action: Action) {
Expand Down Expand Up @@ -102,12 +92,4 @@ export class BindingObserver implements ValueListObserverDelegate<Action> {
elementUnmatchedValue(element: Element, action: Action) {
this.disconnectAction(action)
}

elementMatchedNoValue(token: Token) {
const action = Action.forToken(token)
this.context.handleWarning(
`Action "${token.content}" references undefined controller "${action.identifier}"`,
`connecting action "${token.content}"`
)
}
}
11 changes: 1 addition & 10 deletions src/core/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import { ErrorHandler } from "./error_handler"
import { Module } from "./module"
import { Schema } from "./schema"
import { Scope } from "./scope"
import { TargetGuide } from "./target_guide"
import { ValueObserver } from "./value_observer"
import { TargetObserver, TargetObserverDelegate } from "./target_observer"

export class Context implements ErrorHandler, TargetObserverDelegate {
readonly module: Module
readonly scope: Scope
readonly controller: Controller
readonly targetGuide: TargetGuide
private bindingObserver: BindingObserver
private valueObserver: ValueObserver
private targetObserver: TargetObserver
Expand All @@ -23,7 +21,6 @@ export class Context implements ErrorHandler, TargetObserverDelegate {
this.module = module
this.scope = scope
this.controller = new module.controllerConstructor(this)
this.targetGuide = new TargetGuide(this.scope, this.controller)
this.bindingObserver = new BindingObserver(this, this.dispatcher)
this.valueObserver = new ValueObserver(this, this.controller)
this.targetObserver = new TargetObserver(this, this)
Expand Down Expand Up @@ -94,13 +91,7 @@ export class Context implements ErrorHandler, TargetObserverDelegate {
this.application.handleError(error, `Error ${message}`, detail)
}

// Logging

handleWarning(warning: string, message: string, detail: object = {}) {
const { identifier, controller, element } = this
detail = Object.assign({ identifier, controller, element }, detail)
this.application.handleWarning(warning, `Warning ${message}`, detail)
}
// Debug logging

logDebugActivity = (functionName: string, detail: object = {}): void => {
const { identifier, controller, element } = this
Expand Down
12 changes: 2 additions & 10 deletions src/core/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class Router implements ScopeObserverDelegate {

unloadIdentifier(identifier: string) {
const module = this.modulesByIdentifier.get(identifier)

if (module) {
this.disconnectModule(module)
}
Expand All @@ -85,17 +84,10 @@ export class Router implements ScopeObserverDelegate {
}

scopeConnected(scope: Scope) {
const { identifier, element } = scope
this.scopesByIdentifier.add(identifier, scope)
const module = this.modulesByIdentifier.get(identifier)
this.scopesByIdentifier.add(scope.identifier, scope)
const module = this.modulesByIdentifier.get(scope.identifier)
if (module) {
module.connectContextForScope(scope)
} else {
this.application.handleWarning(
`Element references undefined controller "${identifier}"`,
`Warning connecting controller "${identifier}"`,
{ identifier, element }
)
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/core/scope_observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export class ScopeObserver implements ValueListObserverDelegate<Scope> {
}
}

elementMatchedNoValue(token: Token) {}

private fetchScopesByIdentifierForElement(element: Element) {
let scopesByIdentifier = this.scopesByIdentifierByElement.get(element)
if (!scopesByIdentifier) {
Expand Down
123 changes: 0 additions & 123 deletions src/core/target_guide.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/core/target_properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ export function TargetPropertiesBlessing<T>(constructor: Constructor<T>) {
}, {} as PropertyDescriptorMap)
}

export type TargetDescriptor = {
identifier: string | null
target: string | null
attribute: string
legacy: Boolean
element: Element
}

function propertiesForTargetDefinition(name: string) {
return {
[`${name}Target`]: {
Expand Down
3 changes: 0 additions & 3 deletions src/mutation-observers/value_list_observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export interface ValueListObserverDelegate<T> {
parseValueForToken(token: Token): T | undefined
elementMatchedValue(element: Element, value: T): void
elementUnmatchedValue(element: Element, value: T): void
elementMatchedNoValue(token: Token): void
}

interface ParseResult<T> {
Expand Down Expand Up @@ -55,8 +54,6 @@ export class ValueListObserver<T> implements TokenListObserverDelegate {
if (value) {
this.fetchValuesByTokenForElement(element).set(token, value)
this.delegate.elementMatchedValue(element, value)
} else {
this.delegate.elementMatchedNoValue(token)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/tests/cases/application_test_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class ApplicationTestCase extends DOMTestCase {
try {
this.setupApplication()
this.application.start()
this.application.warnings = false
await super.runTest(testName)
} finally {
this.application.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ export default class ValueListObserverTests extends ObserverTestCase implements
this.recordCall("elementMatchedValue", element, value.id, value.token.content)
}

elementMatchedNoValue(token: Token) {
this.recordCall("elementMatchedNoValue", token)
}

elementUnmatchedValue(element: Element, value: Value) {
this.recordCall("elementUnmatchedValue", element, value.id, value.token.content)
}
Expand Down

0 comments on commit 477e118

Please sign in to comment.