       @browserPluginNode.removeAttribute webViewConstants.ATTRIBUTE_INTERNALINSTANCEID
       @internalInstanceId = parseInt newValue
 
-      if !!@guestInstanceId and @guestInstanceId != 0
-        isNewWindow = if @deferredAttachState then @deferredAttachState.isNewWindow else false
-        params = @buildAttachParams isNewWindow
-        guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
+      return unless @guestInstanceId
+
+      guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w
 
   onSizeChanged: (webViewEvent) ->
     newWidth = webViewEvent.newWidth


    @beforeFirstNavigation = true
    @contentWindow = null
    # Used to save some state upon deferred attachment.
    # If <object> bindings is not available, we defer attachment.
    # This state contains whether or not the attachment request was for
    # newwindow.
    @deferredAttachState = null

    # on* Event handlers.
    @on = {}

  onAttach: (storagePartitionId) ->
    @attributes[webViewConstants.ATTRIBUTE_PARTITION].setValue storagePartitionId

  buildAttachParams: ->
    instanceId: @viewInstanceId
    userAgentOverride: @userAgentOverride
    # Attributes:
    allowtransparency: @attributes[webViewConstants.ATTRIBUTE_ALLOWTRANSPARENCY].getValue()
    autosize: @attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue()
    maxheight: parseInt @attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() || 0
    maxwidth: parseInt @attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() || 0
    minheight: parseInt @attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() || 0
    minwidth: parseInt @attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() || 0
    src: @attributes[webViewConstants.ATTRIBUTE_SRC].getValue()
    httpreferrer: @attributes[webViewConstants.ATTRIBUTE_HTTPREFERRER].getValue()

  attachWindow: (guestInstanceId) ->
    @guestInstanceId = guestInstanceId
    params = @buildAttachParams()

    unless @isPluginInRenderTree()
      return true

    guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w

# Registers browser plugin <object> custom element.
