the-grid / Flowerflip

Layout solver
MIT License
12 stars 4 forks source link

isSubtypeOf "textual" #39

Open paulyoung opened 9 years ago

paulyoung commented 9 years ago

I would have expected these to return true:

isSubtypeOf "textual", "headline"
isSubtypeOf "textual", "h1"

Is there a reason why they don't?


(Previously asked in the-grid/poly/issues/13)

bergie commented 9 years ago

We have tests for those: https://github.com/the-grid/Flowerflip/blob/master/spec/Choice.coffee#L283

...and it passes https://magnum.travis-ci.com/the-grid/Flowerflip#L250

paulyoung commented 9 years ago

This appears to be the reason it doesn't return true:

screen shot 2015-04-07 at 4 45 22 pm

This is how it's currently being used:

{isSubtypeOf} = require "flowerflip/lib/schema"

class Content
  ...
  _computeGetBlock: =>
    ...
    return (block) =>
      for type in isSubtypeOfs
        return false unless isSubtypeOf block.type, type
      ...
      true
  ...
paulyoung commented 9 years ago

This works:

schema = require "flowerflip/lib/schema"

class Content
  ...
  _computeGetBlock: =>
    ...
    return (block) =>
      for type in isSubtypeOfs
        return false unless schema.isSubtypeOf.call schema, block.type, type
      ...
      true
  ...