Just the explanation I wanted. Thanks! :-)


Oliver Joseph Ash
Software Engineer


On 30 April 2014 17:01, Sébastien Cevey <notifications@github.com> wrote:

> In src/plugins/core/formatters/html/enforce-p-elements.js:
>
> > -      } else {
> > -        var isBlockGroup = isBlockElement(group[0]);
> > -        if (isBlockGroup === isBlockElement(binChildNode)) {
> > -          group.push(binChildNode);
> > -        } else {
> > -          startNewGroup();
> > -        }
> > -      }
> > -
> > -      return accumulator;
> > -
> > -      function startNewGroup() {
> > -        var newGroup = [binChildNode];
> > -        accumulator.push(newGroup);
> > +  return function () {
> > +    return function (scribe) {
>
> My rule of thumb would be for all api things not to depend on scribe, but
> receive scribe as a parameter. For things like selection, you could then
> hide this away by adding a helper on the scribe instance like scribe.getSelection
> = function(){ return new this.api.Selection(this); } or something. But
> generally, I'd not use consistency with what I'd consider an anti-pattern
> to drive the constraints on the API.
>
> One reason, for instance, is that if you want to unit test a plugin that
> uses one of the simple element helpers, you end up needing to instanciate a
> whole Scribe instance!
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/guardian/scribe/pull/140/files#r12150891>
> .
>

-- 

------------------------------
Visit theguardian.com.  On your mobile, download the Guardian iPhone app 
theguardian.com/iphone and our iPad edition theguardian.com/ipad<http://theguardian.com/iPad>. 
 Save up to 57% by subscribing to the Guardian and Observer - choose the 
papers you want and get full digital access.  Visit 
subscribe.theguardian.com

This e-mail and all attachments are confidential and may also be 
privileged. If you are not the named recipient, please notify the sender 
and delete the e-mail and all attachments immediately. Do not disclose the 
contents to another person. You may not use the information for any 
purpose, or store, or copy, it in any way.  Guardian News & Media Limited 
is not liable for any computer viruses or other material transmitted with 
or as part of this e-mail. You should employ virus checking software.
 
Guardian News & Media Limited is a member of Guardian Media Group plc. Registered 
Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP.  Registered 
in England Number 908396