public void Connect(INode target, IDictionary <String, Object> options) { if (options == null) { throw new ArgumentNullException("options"); } var init = new MutationObserverInit { AttributeFilters = options.TryGet("attributeFilter") as IEnumerable <String>, IsObservingAttributes = options.TryGet <Boolean>("attributes"), IsObservingChildNodes = options.TryGet <Boolean>("childList") ?? false, IsObservingCharacterData = options.TryGet <Boolean>("characterData"), IsObservingSubtree = options.TryGet <Boolean>("subtree") ?? false, IsExaminingOldAttributeValue = options.TryGet <Boolean>("attributeOldValue"), IsExaminingOldCharacterData = options.TryGet <Boolean>("characterDataOldValue") }; Connect(target, init); }
public MutationObserving(INode target, MutationObserverInit options) { _target = target; _options = options; _transientNodes = new List <INode>(); }
/// <summary> /// Registers the MutationObserver instance to receive notifications of /// DOM mutations on the specified node. /// </summary> /// <param name="target"> /// The Node on which to observe DOM mutations. /// </param> /// <param name="options"> /// Specifies which DOM mutations should be reported. /// </param> public void Connect(INode target, MutationObserverInit options) { var node = target as Node; if (node == null) { return; } else if (options == null) { options = new MutationObserverInit(); } if (options.IsExaminingOldCharacterData.HasValue == false) { options.IsExaminingOldCharacterData = false; } if (options.IsExaminingOldAttributeValue.HasValue == false) { options.IsExaminingOldAttributeValue = false; } if (options.IsObservingAttributes.HasValue == false) { options.IsObservingAttributes = options.IsExaminingOldAttributeValue.Value || options.AttributeFilters != null; } if (options.IsObservingCharacterData.HasValue == false) { options.IsObservingCharacterData = options.IsExaminingOldCharacterData.HasValue && options.IsExaminingOldCharacterData.Value; } if (options.IsExaminingOldAttributeValue.Value && options.IsObservingAttributes.Value == false) { throw new DomException(DomError.TypeMismatch); } if (options.AttributeFilters != null && options.IsObservingAttributes.Value == false) { throw new DomException(DomError.TypeMismatch); } if (options.IsExaminingOldCharacterData.Value && options.IsObservingCharacterData.Value == false) { throw new DomException(DomError.TypeMismatch); } if (options.IsObservingChildNodes == false && options.IsObservingCharacterData.Value == false && options.IsObservingAttributes.Value == false) { throw new DomException(DomError.Syntax); } node.Owner.Mutations.Register(this); var existing = this[target]; if (existing != null) { existing.TransientNodes.Clear(); _observing.Remove(existing); } _observing.Add(new MutationObserving(target, options)); }
public MutationObserving(INode target, MutationObserverInit options) { _target = target; _options = options; _transientNodes = new List<INode>(); }
public void Connect(INode target, IDictionary<String, Object> options) { if (options == null) throw new ArgumentNullException("options"); var init = new MutationObserverInit { AttributeFilters = options.TryGet("attributeFilter") as IEnumerable<String>, IsObservingAttributes = options.TryGet<Boolean>("attributes"), IsObservingChildNodes = options.TryGet<Boolean>("childList") ?? false, IsObservingCharacterData = options.TryGet<Boolean>("characterData"), IsObservingSubtree = options.TryGet<Boolean>("subtree") ?? false, IsExaminingOldAttributeValue = options.TryGet<Boolean>("attributeOldValue"), IsExaminingOldCharacterData = options.TryGet<Boolean>("characterDataOldValue") }; Connect(target, init); }
/// <summary> /// Registers the MutationObserver instance to receive notifications of /// DOM mutations on the specified node. /// </summary> /// <param name="target"> /// The Node on which to observe DOM mutations. /// </param> /// <param name="options"> /// Specifies which DOM mutations should be reported. /// </param> public void Connect(INode target, MutationObserverInit options) { var node = target as Node; if (node == null) return; else if (options == null) options = new MutationObserverInit(); if (options.IsExaminingOldCharacterData.HasValue == false) options.IsExaminingOldCharacterData = false; if (options.IsExaminingOldAttributeValue.HasValue == false) options.IsExaminingOldAttributeValue = false; if (options.IsObservingAttributes.HasValue == false) options.IsObservingAttributes = options.IsExaminingOldAttributeValue.Value || options.AttributeFilters != null; if (options.IsObservingCharacterData.HasValue == false) options.IsObservingCharacterData = options.IsExaminingOldCharacterData.HasValue && options.IsExaminingOldCharacterData.Value; if (options.IsExaminingOldAttributeValue.Value && options.IsObservingAttributes.Value == false) throw new DomException(DomError.TypeMismatch); if (options.AttributeFilters != null && options.IsObservingAttributes.Value == false) throw new DomException(DomError.TypeMismatch); if (options.IsExaminingOldCharacterData.Value && options.IsObservingCharacterData.Value == false) throw new DomException(DomError.TypeMismatch); if (options.IsObservingChildNodes == false && options.IsObservingCharacterData.Value == false && options.IsObservingAttributes.Value == false) throw new DomException(DomError.Syntax); node.Owner.Mutations.Register(this); var existing = this[target]; if (existing != null) { existing.TransientNodes.Clear(); _observing.Remove(existing); } _observing.Add(new MutationObserving(target, options)); }