예제 #1
0
        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);
        }
예제 #2
0
 public MutationObserving(INode target, MutationObserverInit options)
 {
     _target         = target;
     _options        = options;
     _transientNodes = new List <INode>();
 }
예제 #3
0
        /// <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));
        }
예제 #4
0
 public MutationObserving(INode target, MutationObserverInit options)
 {
     _target = target;
     _options = options;
     _transientNodes = new List<INode>();
 }
예제 #5
0
        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);
        }
예제 #6
0
        /// <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));
        }